You now know the whole language. This closing chapter is about craft — writing HTML that is clean, valid, accessible and fast, and the habits that keep a codebase healthy as it grows. Good HTML is the quiet foundation every other layer sits on.
Clean, semantic markup
- Choose the element that describes the content's meaning, not its appearance — that's what styling is for.
- Reserve
<div>/<span>for when no semantic element fits. - Indent consistently and keep nesting shallow; deeply nested markup is a smell.
- Lowercase tags and attributes; quote attribute values.
Validation
Run your HTML through the W3C validator. It catches unclosed tags, misused attributes, duplicate ids and nesting errors — bugs that cause weird rendering and break accessibility:
Common mistakes
| Mistake | Fix |
|---|---|
| Multiple <h1>s / skipped levels | One <h1>; logical h2–h6 outline |
| Missing alt on images | Describe it, or alt="" if decorative |
| <div onclick> instead of <button> | Use the native interactive element |
| Duplicate id on a page | ids must be unique; use class instead |
| Inline styles everywhere | Move to a CSS file with classes |
Performance habits
- Set image
width/height, useloading="lazy"and modern formats (Chapter 11). - Put scripts at the end of
<body>or usedeferso content renders first. - Keep the markup lean — every extra element is bytes and layout work.
Practice
Take an earlier page you built, run it through the W3C validator, and fix every error and warning. Then review it against the common-mistakes table — one h1, alt on every image, native buttons, unique ids, no inline styles. You've now completed HTML end to end.
Key takeaways
- 01Write semantic markup — pick elements by meaning; div/span only when nothing else fits.
- 02Validate with the W3C validator to catch unclosed tags, duplicate ids and nesting errors.
- 03Avoid the classics: multiple h1s, missing alt, <div onclick>, duplicate ids, inline styles.
- 04Keep pages fast: sized/lazy images, deferred scripts, lean markup.
- 05Clean, valid, accessible HTML is the foundation every other layer builds on.
