For AI agents: the complete documentation index is available at https://nhanbe.id.vn/llms.txt, the full documentation bundle is available at https://nhanbe.id.vn/llms-full.txt, and this page is available as Markdown at https://nhanbe.id.vn/building-for-the-web/semantic-html.md.
What semantic HTML is, why it matters, and a practical reference for every relevant element - document structure, text, lists, tables, forms, media, and interactive elements.
Semantic HTML means using elements that describe their meaning rather than their appearance. A <nav> tells browsers, screen readers, and search engines "this is navigation" - a <div class="nav"> tells them nothing.
Screen readers use semantic elements to build a navigable page outline. A <main> element lets users skip to content; headings create a table of contents.
SEO
Search engines use semantic structure to understand page content. <article>, <h1>-<h6>, and <time> all provide ranking signals.
Maintainability
Semantic markup is self-documenting. Reading <aside> is faster than deciphering <div class="sidebar-content-wrapper">.
Default behaviour
Many semantic elements come with built-in functionality - <details> is collapsible, <dialog> manages focus, <form> handles submission. No JavaScript required.
Interoperability
RSS readers, read-mode browsers, and AI tools extract content more reliably from semantic markup.
The dominant content of the page. There must be only one<main> per page, and it must not be nested inside <header>, <nav>, <footer>, <article>, or <aside>.
<body> <header><!-- site header --></header> <main> <h1>Semantic HTML Reference</h1> <p>Content goes here.</p> </main> <footer><!-- site footer --></footer></body>
Screen readers offer a "skip to main content" shortcut that targets this element.
A thematic grouping of content, typically with a heading. Use it when content forms a distinct section of a document.
<section aria-labelledby="features-heading"> <h2 id="features-heading">Features</h2> <p>Our platform provides...</p></section><section aria-labelledby="pricing-heading"> <h2 id="pricing-heading">Pricing</h2> <p>Choose the plan that fits...</p></section>
<section> vs <div>: If the grouping has a heading and represents a standalone concept, use <section>. If you only need a wrapper for styling, use <div>.
Self-contained content that makes sense on its own - a blog post, news story, forum post, product card, or comment.
<article> <header> <h2>Understanding Semantic HTML</h2> <time datetime="2025-03-15">15 March 2025</time> </header> <p>Semantic HTML is the practice of using...</p> <footer> <p>Written by <a href="/authors/luca">Luca</a></p> </footer></article>
Articles can be nested (e.g. an article with nested comment articles).
Headings (<h1> through <h6>) create an outline that screen readers and search engines use to understand content hierarchy.
<h1>Page Title</h1> <!-- one per page --><h2>Major Section</h2><h3>Subsection</h3><h3>Subsection</h3><h2>Another Major Section</h2><h3>Subsection</h3><h4>Sub-subsection</h4>
<!-- Paragraph - the default block of text --><p>This is a paragraph of text.</p><!-- Line break - only for content where breaks matter (poems, addresses) --><address> 123 Main Street<br> Springfield, IL 62701</address>
Do not use <br> for spacing - use CSS margin or padding instead.
<blockquote cite="https://www.w3.org/WAI/"> <p>The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.</p> <footer>-- <cite>Tim Berners-Lee</cite></footer></blockquote>
Rendered:
The power of the Web is in its universality. Access by everyone
regardless of disability is an essential aspect.
Self-contained content with an optional caption - images, diagrams, code listings, tables.
<figure> <img src="/chart.png" alt="Monthly revenue growth from January to June" width="800" height="400"> <figcaption>Fig. 1: Revenue grew 23% from Q1 to Q2.</figcaption></figure><!-- Also works for code --><figure> <pre><code>const greeting = "Hello, world!";</code></pre> <figcaption>A simple JavaScript variable declaration.</figcaption></figure>
Items where order matters - steps, rankings, instructions:
<ol> <li>Clone the repository</li> <li>Install dependencies</li> <li>Start the dev server</li></ol><!-- Start from a different number --><ol start="5"> <li>Fifth item</li> <li>Sixth item</li></ol><!-- Reversed --><ol reversed> <li>Bronze</li> <li>Silver</li> <li>Gold</li></ol>
<dl> <dt>HTML</dt> <dd>HyperText Markup Language - the standard language for web pages.</dd> <dt>CSS</dt> <dd>Cascading Style Sheets - controls the visual presentation of HTML.</dd> <dt>JavaScript</dt> <dd>A programming language for interactive web content.</dd></dl>
Rendered:
HTML
HyperText Markup Language - the standard language for web pages.
CSS
Cascading Style Sheets - controls the visual presentation of HTML.
JavaScript
A programming language for interactive web content.
A <dt> can have multiple <dd> values, and multiple <dt> terms can share a <dd>.
<audio controls preload="metadata"> <source src="podcast.mp3" type="audio/mpeg"> <source src="podcast.ogg" type="audio/ogg"> <p>Your browser does not support HTML audio. <a href="podcast.mp3">Download the episode</a>.</p></audio>
Several HTML elements on this page — <dialog>, <details>, <popover> — have uneven browser support. Add the MDN MCP server to your IDE or Claude Code and ask "what is the browser support for <dialog>?" to get a live compatibility table straight from MDN.
Semantic HTML is not extra work - it is the default way to write HTML. Every time you reach for a <div> or <span>, ask: "Is there an element that already describes what this content is?" If yes, use it. You get accessibility, SEO, built-in behaviour, and self-documenting code for free.