$html-docs
InstallDevelopersPricingSign inOpen drive
All HTML guides
Foundations7 min read·July 29, 2026

How to Write Semantic HTML That Stays Useful

Choose elements for their meaning, build a clear document outline, and make your page easier to navigate, edit, and reuse.

The short version

Use the element that describes the job of the content before reaching for a generic div.

01

Start with meaning, not appearance

Semantic HTML describes what a piece of content is. A heading is a heading, a navigation block is navigation, and a self-contained story is an article. CSS can change how any of those elements look; the markup should keep describing the content when the styles are removed.

That separation pays off everywhere. Screen readers can expose useful landmarks, search engines can understand the page more reliably, and future editors can change a section without reverse-engineering a wall of generic containers.

  • Use header, main, nav, aside, and footer for major page regions.
  • Use article for content that could stand on its own.
  • Use section when the group has a meaningful heading.
  • Use button for actions and a for navigation.
02

Build the smallest honest structure

Do not replace every div with a semantic element. A div is correct when a wrapper has no meaning beyond layout or styling. The goal is an honest outline, not the maximum possible number of named elements.

html
<header>
  <nav aria-label="Primary">…</nav>
</header>
<main>
  <article>
    <h1>Quarterly product review</h1>
    <section aria-labelledby="results">
      <h2 id="results">Results</h2>
      …
    </section>
  </article>
</main>
<footer>…</footer>
03

Review the page without CSS

A useful final check is to disable styles or inspect the accessibility tree. The reading order should still make sense, every region should have a clear purpose, and interactive controls should still identify what they do.

HTML Docs preserves this kind of structure when a page is imported, which makes region-level editing and review much easier than working with one opaque HTML blob.

Official references

  • WHATWG: Semantics
  • W3C WAI: Page structure

In this guide

  1. 01Start with meaning, not appearance
  2. 02Build the smallest honest structure
  3. 03Review the page without CSS
Publish a page

Keep going

Related HTML guides

Browse all 24 guides
Foundations6 min read

A Reusable HTML Page Structure for New Projects

Begin with a small, valid document shell that supports accessibility, responsive design, metadata, and progressive enhancement.

Read guide
Foundations7 min read

How to Organize CSS Around Your HTML

Keep selectors shallow, components readable, and design tokens explicit so a page remains easy to revise after launch.

Read guide
Foundations6 min read

How to Add Dark Mode Without Breaking Your HTML

Respect system preferences, preserve contrast, and keep native controls and embedded content legible in both themes.

Read guide
© 2026 HTML DocsInstallSupportPrivacyTermsAPI