Free, independent guides since 2010

Code

Semantic HTML5 elements explained

Header, nav, main, article, section, aside and footer: how semantic HTML5 elements give your pages meaning for browsers, screen readers and search engines.

<guide section="Code" type="guide" read="2 min"/>

In the early days of the web, pages were built from tables and endless <div> elements. They looked fine, but the code said nothing about what each part was. HTML5 introduced a set of semantic elements that describe the role of content. Our older guides on HTML document tags and logical HTML tags explain the classic building blocks; this page adds the modern layer on top.

The main page landmarks

ElementUse it for
<header>Introductory content: logo, site name, sometimes the main navigation. Also usable at the top of an article.
<nav>Major blocks of navigation links, such as the main menu or a table of contents.
<main>The main content of the page. Use it once per page.
<article>Content that makes sense on its own: a blog post, a product card, a comment.
<section>A thematic group of content, normally with its own heading.
<aside>Related but secondary content: a sidebar, a tip box, related links.
<footer>Closing information: copyright, contact, links. Also usable at the end of an article.

A typical page skeleton

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Choosing a web host – My site</title>
</head>
<body>
  <header>
    <a href="/">My site</a>
    <nav aria-label="Main">
      <a href="/hosting">Hosting</a>
      <a href="/domains">Domains</a>
    </nav>
  </header>
  <main>
    <article>
      <h1>Choosing a web host</h1>
      <p>…</p>
      <section>
        <h2>Shared hosting</h2>
        <p>…</p>
      </section>
    </article>
    <aside>
      <h2>Related articles</h2>
    </aside>
  </main>
  <footer>© 2026 My site</footer>
</body>
</html>

Smaller semantic elements worth knowing

  • <figure> and <figcaption> – an image, chart or code sample with its caption. See also images in HTML.
  • <time datetime="2026-03-15"> – a date or time that machines can read.
  • <details> and <summary> – a native, accessible show/hide block, ideal for FAQs.
  • <mark> – highlighted text, for example search terms.
  • <address> – contact information for the page or article author.
  • <dialog> – a native modal or pop-up window.

Headings: the real outline of your page

Screen reader users often jump from heading to heading, and search engines use headings to understand the structure of a page. Use exactly one <h1> for the page title, then <h2> for main sections and <h3> for subsections. Never pick a heading level because of its font size – that is a job for CSS.

Why it matters

Semantic HTML is the foundation of web accessibility: assistive technology uses landmarks to let people skip straight to the content. It also makes your code easier to read for the next developer and helps search engines separate your content from menus and footers. The authoritative reference for every element is the MDN HTML elements reference.

Frequently asked questions

Do semantic elements improve SEO?

They are not a magic ranking factor, but they help search engines understand which part of the page is the main content and which parts are navigation or boilerplate. That clarity, plus better accessibility, is worth it.

Can I still use div?

Yes. div is perfect for grouping things purely for styling. Use a semantic element when there is one that describes the content.