Skip to main content
Albero Academy

Best Practices & Validation

Tie it together — write clean, valid, semantic HTML, validate it, avoid common mistakes, and keep pages fast and maintainable.

Chapter 16HTML13 min readBeginner friendly
  • #HTML
  • #Best Practices
  • #Validation

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

MistakeFix
Multiple <h1>s / skipped levelsOne <h1>; logical h2–h6 outline
Missing alt on imagesDescribe it, or alt="" if decorative
<div onclick> instead of <button>Use the native interactive element
Duplicate id on a pageids must be unique; use class instead
Inline styles everywhereMove to a CSS file with classes

Performance habits

  • Set image width/height, use loading="lazy" and modern formats (Chapter 11).
  • Put scripts at the end of <body> or use defer so 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

  1. 01Write semantic markup — pick elements by meaning; div/span only when nothing else fits.
  2. 02Validate with the W3C validator to catch unclosed tags, duplicate ids and nesting errors.
  3. 03Avoid the classics: multiple h1s, missing alt, <div onclick>, duplicate ids, inline styles.
  4. 04Keep pages fast: sized/lazy images, deferred scripts, lean markup.
  5. 05Clean, valid, accessible HTML is the foundation every other layer builds on.