Chapter 12 of 15

Semantic HTML: Better SEO and Accessibility

Semantic means "with meaning". Semantic tags tell Google and screen readers what each part of your page is.

Why it matters

<div> says nothing about its content. <nav> says "this is the menu". This helps:

Left: five div tags. Right: header, nav, main, article, footer tags
Both pages look the same, but the semantic one is easier for Google and screen readers.
  • Search engines understand your page better.
  • Blind users can jump straight to the menu or main content with their screen reader.
  • You, because the code is easier to read.

The main layout tags

A page layout labelled header with nav, main with article and sections, aside, and footer
Each part of the page has a tag that says what it is.
HTML
<body>
  <header>
    <a href="/">Logo</a>
    <nav>
      <a href="/">Home</a>
      <a href="/blog.html">Blog</a>
    </nav>
  </header>

  <main>
    <article>
      <h1>How to Make Masala Chai</h1>
      <section>
        <h2>Ingredients</h2>
        ...
      </section>
    </article>
    <aside>Related recipes</aside>
  </main>

  <footer>© 2026 My Site</footer>
</body>
TagMeaning
headerTop part: logo, title, menu
navMain navigation links
mainThe main content. Only one per page.
articleA complete piece that makes sense alone: blog post, news story, product
sectionA part of a page with its own heading
asideSide content: related links, ads, tips
footerBottom part: copyright, contact, links

More useful meaningful tags

HTML
<figure>
  <img src="chart.png" alt="Sales went up 20% in March">
  <figcaption>Monthly sales in 2026</figcaption>
</figure>

<time datetime="2026-12-03">3 December 2026</time>

<blockquote>A short quote from someone.</blockquote>

<button type="button">Open menu</button>

Small tags with meaning

TagUse it forExample
<address>Contact detailsEmail, phone, office address
<mark>Highlighted textSearch words found in a result
<abbr>Short forms<abbr title="Search Engine Optimisation">SEO</abbr>
<code>Code in a sentenceUse the p tag
<small>Side notes, legal text"Prices include tax"

Accessibility in 6 steps

Accessibility means everyone can use your site, including people who are blind, cannot use a mouse, or have poor eyesight. It also helps SEO, because Google reads pages in a similar way. These six steps cover most of it:

  1. Alt text on every meaningful image.
  2. Labels on every form field (see the Forms chapter).
  3. Headings in order: one h1, then h2, then h3.
  4. Strong contrast: dark text on light, or light on dark. Light grey on white is hard to read.
  5. Keyboard works: press Tab through your page. You should always see where you are.
  6. Clear link text: "Download the price list", not "click here".

Mini project: from divs to meaning

Here is a page built only with divs. Rewrite it with semantic tags.

HTML
<div class="top">
  <div class="logo">Spice Kitchen</div>
  <div class="menu"><a href="#">Menu</a> <a href="#">Order</a></div>
</div>
<div class="content">
  <div class="post">
    <div class="title">Our new mango lassi</div>
    <div>Made with fresh Alphonso mangoes.</div>
  </div>
</div>
<div class="bottom">Call us: 98000 00000</div>

One possible answer:

HTML
<header>
  <a href="/" class="logo">Spice Kitchen</a>
  <nav><a href="#">Menu</a> <a href="#">Order</a></nav>
</header>
<main>
  <article>
    <h1>Our new mango lassi</h1>
    <p>Made with fresh Alphonso mangoes.</p>
  </article>
</main>
<footer>
  <address>Call us: <a href="tel:+919800000000">98000 00000</a></address>
</footer>

It looks the same in the browser, but now Google knows the title, the article and the contact details, and a phone user can tap the number to call.

How to test your page

  • Keyboard test: unplug the mouse and use only Tab, Enter and the arrow keys.
  • Lighthouse: in Chrome DevTools, open the Lighthouse tab and run a report. It scores accessibility and SEO and lists what to fix.
  • Screen reader: Windows has Narrator and Mac has VoiceOver built in. Listen to your page for one minute. You will quickly hear what is missing.

Practice time

  1. Rebuild your home page using header, nav, main and footer.
  2. Put your blog post inside <article> with sections.
  3. Wrap an image and its caption in <figure>.
  4. Run a Lighthouse report on your page and fix the first two problems.
  5. Add a skip link to your site and test it with the Tab key.

Quick summary

  • Semantic tags describe what content is.
  • They help SEO, accessibility and readable code.
  • Use a to go somewhere, button to do something.