HTML describes content and structure; CSS controls presentation and layout. Keeping those responsibilities clear improves accessibility, maintainability, performance, and the ability of search engines and assistive technologies to understand a page.
Before You Begin
- A text editor and a modern browser.
- Basic familiarity with files, folders, and a local web server.
- A target page or component to build.
Recommended Approach
1. Start with a valid document
Use a doctype, language attribute, character encoding, viewport metadata, descriptive title, and meaningful page landmarks. Use headings in a logical hierarchy rather than choosing heading levels for appearance.
2. Choose semantic HTML
Use elements such as `header`, `nav`, `main`, `article`, `section`, and `footer` according to their meaning. Use buttons for actions and links for navigation. Provide labels for form controls.
3. Write CSS with predictable scope
Prefer reusable classes over broad selectors that unintentionally affect unrelated pages. Use CSS variables for repeated colors and spacing, and avoid unnecessary specificity.
4. Build responsive layouts
Use flexible widths, grid or flexbox, and media queries where needed. Test narrow screens, zoom, long text, and keyboard navigation instead of designing only for one desktop size.
5. Validate and inspect
Use browser developer tools to inspect layout and network requests. Check console errors, missing assets, contrast, keyboard focus, and HTML validation warnings.
Operational Considerations
Keep the implementation small enough to understand and test. Separate presentation, request handling, validation, and business logic so a change in one layer does not silently alter another. Define what the function or endpoint accepts and returns, and treat browser input, external API responses, and uploaded files as untrusted. Use version control and make changes in small increments that can be reviewed and reverted.
How to Verify the Result
Test more than the successful example. Include missing fields, malformed values, unusually large input, repeated submissions, slow responses, network failures, and unauthorized requests. Use browser developer tools and server logs together, but avoid recording secrets or sensitive payloads. Check keyboard access and responsive layouts for frontend changes, and add automated tests for backend validation and important business rules.
Example Configuration
Illustrative example — adapt values to your environment
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example page</title>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<main><h1>Page heading</h1></main>
</body>
</html>
Common Mistakes to Avoid
- Do not use a clickable `div` when a button or link is the correct semantic element.
- Do not rely on color alone to communicate errors or status.
- Avoid fixed widths that cause horizontal scrolling on phones.
Make one change at a time, test it from the perspective of the actual user or application, and record the reason for the change. Keep a rollback path for network, identity, and production configuration changes.
Final Checklist
- The configuration matches the intended environment and service version.
- Access is limited to the required identities, resources, ports, and operations.
- The expected workflow has been tested, including a negative test for unauthorized access.
- Secrets and temporary credentials are protected and excluded from logs and source control.
- The configuration owner, purpose, and review or expiration date are documented.