HTML5 Semantic Elements Guide
Short answer: semantic HTML elements describe the meaning of the content they wrap, not just how it looks. Using <header>, <nav>, <main>, <article>, <section>, <aside> and <footer> instead of generic <div> tags makes pages easier for search engines, screen readers and developers to understand.
Div soup vs semantic markup
<!-- generic, no meaning -->
<div class="header">
<div class="nav">...</div>
</div>
<div class="content">...</div>
<div class="footer">...</div>
<!-- semantic -->
<header>
<nav>...</nav>
</header>
<main>...</main>
<footer>...</footer>
Both look identical once styled, but the second tells browsers and assistive technology what each region is.
The main semantic elements
| Element | Meaning |
|---|---|
<header> | Introductory content for a page or section: logo, title, navigation |
<nav> | A block of major navigation links |
<main> | The main content of the page; use only once and do not nest it in header, footer, nav, aside or article |
<article> | Self-contained content that makes sense on its own: a blog post, news story, product card |
<section> | A thematic group of content, normally with a heading |
<aside> | Related but secondary content: sidebars, callouts |
<footer> | Closing content: copyright, links, author info |
<figure> / <figcaption> | An image, diagram or code sample with a caption |
<time> | A date or time in a machine-readable form |
<address> | Contact information |
A complete page layout
<body>
<header>
<a href="/"><img src="logo.svg" alt="Site name"></a>
<nav aria-label="Main">
<ul>
<li><a href="/blog">Blog</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h1>How to learn HTML</h1>
<p>Published <time datetime="2026-01-15">15 January 2026</time></p>
<section>
<h2>Start with the basics</h2>
<p>...</p>
<figure>
<img src="structure.png" alt="Diagram of an HTML page" width="600" height="400">
<figcaption>The structure of an HTML page</figcaption>
</figure>
</section>
</article>
<aside>
<h2>Related guides</h2>
<ul>...</ul>
</aside>
</main>
<footer>
<p>© 2026 Example Site</p>
</footer>
</body>
Article vs section vs div
- Use
<article>if the content could be shared or syndicated independently. - Use
<section>for a themed part of a page that has its own heading. - Use
<div>when you only need a wrapper for styling and no meaning applies.
Why semantics matter
- Accessibility: screen reader users can jump straight to
main,navor headings using landmarks. See accessibility best practices. - SEO: clear structure helps search engines understand which text is the main content, navigation or supporting material.
- Maintainability: developers read the structure at a glance.
- Built-in behavior: elements like
<button>,<details>and<dialog>provide keyboard support and states for free.
Headings: keep a logical outline
Use a single <h1> per page for the main topic, then <h2>, <h3> in order, without skipping levels just for size. Control the visual size with CSS.
Common mistakes
- Using
<section>as a styling wrapper without a heading. - Several
<main>elements on one page. - Using
<div onclick>instead of a real<button>or<a>. - Choosing headings by appearance rather than structure.
- Marking up layout tables or using
<br>for spacing.
New to HTML? Read what HTML is, then build accessible inputs with HTML forms and tabular data with HTML tables.
FAQs
Do semantic elements change how a page looks?
Not by themselves; browsers apply minimal default styles. You style them with CSS.
Are semantic elements supported in all browsers?
Yes, all current browsers support them.
Does semantic HTML improve rankings?
It helps search engines interpret your content, but it is not a direct ranking trick. Quality content still matters most.
Can I have more than one header or footer?
Yes. A page can have a header and footer, and each <article> or <section> can have its own.
