Professional HTML Composition Guide

This document shows a minimal, professional, semantic HTML composition that focuses on:

Framework-agnostic and aligned with modern accessibility and maintainability best practices.


High-level document structure (always this order)

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- Metadata (one of each type) -->
  </head>

  <body>
    <!-- Page layout -->
  </body>
</html>

Side note:
This structure never changes. If this order is broken, tools, browsers, accessibility tech, and SEO will all suffer.


<head> — mostly single-instance elements

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title></title>

  <!-- Multiple allowed -->
  <meta name="description" content="">
  <link rel="stylesheet" href="">
  <script src="" defer></script>
</head>

Rules

Side note:
Think of <head> as configuration, not content. Nothing here should be visible to the user directly.


<body> — semantic layout skeleton

<body>
  <header></header>
  <nav></nav>

  <main>
    <!-- Page-specific content -->
  </main>

  <footer></footer>
</body>

Rules

Side note:
Screen readers rely heavily on this structure. main is a critical accessibility landmark.


<header> — site-level identity

<header>
  <div>
    <!-- Logo / branding -->
  </div>

  <nav>
    <ul>
      <li><a></a></li>
      <li><a></a></li>
      <li><a></a></li>
    </ul>
  </nav>
</header>

Rules

Side note:
header is not just for the top of the page — articles and sections can have their own headers too.


<main> — page content container

<main>
  <section></section>
  <section></section>
</main>

Rules

Side note:
If content appears on every page, it probably does not belong in main.


<section> — thematic grouping (usually many)

<section>
  <header>
    <h2></h2>
  </header>

  <article></article>
  <article></article>
</section>

Rules

Side note:
If you cannot name a section with a heading, it may just be a div.


<article> — standalone, repeatable content

<article>
  <header>
    <h3></h3>
  </header>

  <p></p>
  <p></p>

  <footer></footer>
</article>

Rules

Side note:
If you could syndicate it via RSS or share it independently, it’s probably an article.


<aside> — secondary or complementary content

<aside>
  <section></section>
</aside>

Rules

Side note:
aside is context-dependent — its meaning changes depending on where it is placed.


<footer>
  <nav>
    <ul>
      <li><a></a></li>
    </ul>
  </nav>

  <small></small>
</footer>

Rules

Side note:
Footers are ideal for legal text, secondary navigation, and metadata — not main content.


Text-level semantics (inside content elements)

<p>
  <strong></strong>
  <em></em>
  <a></a>
  <span></span>
</p>

Rules

Side note:
If you use span a lot, ask yourself if a semantic element already exists.


Common professional nesting rules

❌ Avoid

<a>
  <button></button>
</a>

<p>
  <div></div>
</p>

✅ Correct

<a></a>

<button></button>

<div>
  <p></p>
</div>

Side note:
Invalid nesting often works visually — until accessibility, forms, or JavaScript break.


Mental model (how professionals structure HTML)

html
 └─ body
    ├─ header
    │  └─ nav → ul → li → a
    ├─ main
    │  └─ section
    │     └─ article
    │        ├─ header → h*
    │        ├─ p
    │        └─ footer
    └─ footer

Side note:
This mental model scales from static HTML to React, Angular, Astro, and server-rendered apps.


Key rules summary

ElementCount per pagePurpose
html1Root element
head1Metadata
body1Visible content
main1 onlyPrimary content
header1+Intro / branding
nav0+Navigation
sectionManyThematic grouping
articleManyStandalone content
aside0+Secondary content
footer1+Metadata / closing

Final side note:
Good HTML is about meaning first, styling second, and behavior last.
If the structure is right, everything else becomes easier.