Semantic HTML: Give Your Page a Structure People Can Navigate

A practical guide to meaningful HTML markup and HTML5 structural elements for accessible pages.

Start by identifying the main content, navigation, and page heading before choosing containers. HTML with meaningful structure gives browsers and assistive technology clues about what each part does. HTML5’s structural tags let you express those roles directly in the markup.

What the markup communicates

What is semantic markup? It is markup that describes the purpose of content through the elements chosen for it. A <nav> identifies a navigation region; a <button> identifies an action. A generic <div> can group either one, but its tag alone does not say what the group is for.

Semantic HTML gives the same source document a structure that different tools can interpret. A browser can apply familiar behavior to a button, while a screen reader can expose a navigation landmark. CSS can still control how those elements look. The meaning comes from the element and its context, not from the size or color of its text. In HTML, meaningful markup lets that structure travel with the content. HTML markup with meaning helps a browser distinguish a list from unrelated lines of text.

When choosing semantic elements, HTML offers several levels of specificity. Use <p> for a paragraph, <ul> and <li> for a list, and an <a> with an href for a link to a destination. Use a button for an action such as opening a menu. These choices help users recognize and operate the interface with the controls they expect.

HTML5 semantic elements in a small page

Consider a site with a guide to growing herbs. Its major regions can be expressed like this:

<body>
  <a href="#main-content">Skip to content</a>
  <header>
    <a href="/">Garden Notes</a>
    <nav aria-label="Primary">
      <a href="/guides">Guides</a>
      <a href="/about">About</a>
    </nav>
  </header>
  <main id="main-content">
    <article>
      <h1>Growing basil indoors</h1>
      <p>Give basil a sunny window and well-drained soil.</p>
      <h2>Choose a container</h2>
      <p>Use a pot with drainage holes.</p>
      <h2>Care for the plant</h2>
      <h3>Watering</h3>
      <p>Water when the top of the soil feels dry.</p>
    </article>
    <aside aria-labelledby="related-heading">
      <h2 id="related-heading">Related guide</h2>
      <a href="/mint">Growing mint</a>
    </aside>
  </main>
  <footer><p>Garden Notes</p></footer>
</body>

The page-level header contains the site identity and primary navigation. The main region holds this page’s unique content; the article is a self-contained guide, and the aside offers related material. The footer closes the page with site information. The skip link gives keyboard users a direct route past repeated navigation to the main content.

These HTML5 semantic elements convey different jobs. If a page has two navigation regions, give them distinct accessible labels, such as “Primary” and “Footer,” so a landmark list makes sense. A single navigation region does not need a label just to repeat its role. The W3C page regions guide explains how these regions are exposed and why context matters.

Build a heading path

Read the example’s headings as a table of contents: “Growing basil indoors” is the page topic, the two h2 headings divide it into subjects, and “Watering” is part of the care section. Heading levels describe relationships; use CSS, rather than a different heading level, to change visual size.

This meaningful structure in HTML also helps someone navigating by headings jump to the desired part without listening to every paragraph. The MDN guide to headings recommends logical levels and explains how assistive technologies use them. Give headings descriptive text and avoid skipping from h2 to h4 merely for styling.

This is one practical answer to what semantic markup is: the source tells a reader’s tools that “Watering” is a subsection, not just bold text. The meaning of the markup remains understandable even when styles are changed or removed. HTML’s meaningful markup also gives a developer a clearer map when updating the guide months later. For instance, meaningful HTML markup identifies a list, and a screen reader can announce how many items it contains.

Choose by purpose, then add styling

Suppose the same page used <div class="nav"> for its navigation and <div class="main"> for its content. Those class names can guide CSS, but they do not automatically create navigation and main landmarks. Replacing the wrappers with <nav> and <main> makes those roles available through native HTML. You can keep classes on the new elements for styling.

HTML5 structural tags express the purpose of regions; generic containers remain useful too. A generic container still has a job: group cards into a grid, wrap an icon and label, or provide a styling hook when no more specific element fits. For example, choose <section> for a thematic grouping, usually with a heading, and <article> for content that could stand on its own. A layout wrapper does not need to become a section just because it encloses several children. HTML5 page landmarks work best when their purpose matches the content, not the visual layout.

This distinction makes semantic HTML a design decision, not a rule to remove every <div>. Start with the content’s purpose, then choose a tag and style it. The MDN document-structure guide describes these choices in more detail.

Know what structure can and cannot do

Semantically meaningful HTML provides useful defaults, but it cannot supply missing content or repair broken behavior. A button still needs an understandable name; an image conveying information needs appropriate alternative text; a menu opened by a button must be operable and expose its state. Test the actual interaction with a keyboard and screen reader rather than judging it from the tags alone.

Similarly, HTML5’s elements for page structure do not all become landmarks in every context. A top-level <header> can represent the page banner, while a header inside an article describes that article and is not the page banner. A named <section> may become a region landmark; creating a landmark for every small group can make navigation noisy. W3C’s landmark guidance explains how to keep regions meaningful.

A quick page check

Before shipping, inspect your page in this order:

  1. Find the unique content and place it in one visible <main>; identify major navigation and page-level header and footer.
  2. Read the headings in order. Confirm that each level reflects the relationship between topics and that the wording identifies the content below it.
  3. Inspect links, buttons, images, and forms for meaningful names and appropriate native elements. Try every control with a keyboard.
  4. Open a screen reader’s landmark and heading lists. Check that the names and sequence help you reach the intended content; then test the page itself.

Treat semantic HTML as a map to maintain alongside the visible design. When the page changes, update the map so its signposts still lead to the right places.