Screen reader users can jump between the main parts of a web page using landmarks. A semantic HTML layout gives those regions roles that the browser can expose to assistive technology.

Where an element sits affects the landmark it creates. A page-level <header> introduces the site and a page-level <footer> holds information such as contact details. Inside an article, those elements describe that section instead.

The layout works in a local HTML file without a web server. Desktop Chrome's accessibility tree shows the roles the browser assigns, even before any CSS is added to style the page.

Steps to create a semantic HTML layout:

  1. Create layout.html in a new test folder using your text editor.
    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Community garden</title>
    </head>
    <body>
    </body>
    </html>
  2. Insert the page header immediately after the opening <body> tag.
      <header>
        <p>Community garden</p>
        <nav>
          <a href="#hours">Hours</a>
          <a href="#contact">Contact</a>
        </nav>
      </header>

    The <nav> groups the page's navigation links. Their fragment URLs point to the IDs on the main content and footer.

  3. Add the main content immediately after the closing </header> tag.
      <main id="hours">
        <h1>Opening hours</h1>
        <p>Saturday and Sunday, 9 a.m. to noon.</p>
      </main>

    The <main> element holds the content specific to this page. Its hours ID is the destination of the Hours link.

  4. Insert the page footer immediately before the closing </body> tag.
      <footer id="contact">
        <p>Contact: garden@example.com</p>
      </footer>

    The contact ID is the destination of the Contact link. The header, main content and footer each sit directly inside <body>.

  5. Save layout.html in the test folder.
  6. Open the saved layout.html in desktop Chrome.

    Chrome shows a File badge beside the address. The address shows where you saved layout.html.

  7. Open Chrome DevTools with F12.

    On a Mac, the shortcut is Command + Option + I. If DevTools opens in another panel, select Elements first.

  8. Open the tab overflow menu at the end of the Styles tab row if Accessibility is hidden.
  9. Select Accessibility in the Elements sidebar.
  10. Turn on Show accessibility tree.
  11. Confirm that the accessibility tree shows banner with navigation inside it, followed by main and contentinfo.

    The tree's top row is Community garden. The main branch contains the Opening hours heading. If a role is missing, check that the matching element is present in the saved file and reload the page before checking again.

Share this guide