UndieGravity LogoUndiegravity

Semantic HTML: Better SEO and Accessibility for Free

Semantic elements like header, main, nav, article, and button tell browsers, search engines, and screen readers what your content is. Here is how to use them.

By UndieGravity, , 2 min read

Semantic HTML means choosing elements for their meaning, not their look. A <button> instead of a clickable <div>, a <nav> around navigation links, an <article> around a blog post. It costs nothing, and it improves accessibility and how search engines read your page.

The page landmarks

  • <header>: the site header with logo and navigation.
  • <nav>: a block of navigation links. Label it when there is more than one, for example aria-label="Footer".
  • <main>: the main content. Use exactly one per page.
  • <article>: content that makes sense on its own, such as a post or a product card.
  • <section>: a themed group of content, usually with its own heading.
  • <aside>: related content, such as a sidebar.
  • <footer>: footer of the page or of an article.

Screen reader users can jump between these landmarks directly, the same way sighted users scan a page.

Headings form an outline

Use one <h1> for the page topic, then <h2> for sections and <h3> inside them. Do not skip levels to get a smaller font; change the size with CSS instead. A clear outline helps search engines and AI tools pick out the main topics and answers on your page.

  • A link (<a href>) goes somewhere: another page or a section.
  • A button (<button>) does something: submits a form, opens a menu.
  • A <div onclick> is neither. It cannot be focused with the keyboard and screen readers do not announce it as clickable.

Forms

<label for="email">Email</label>
<input id="email" name="email" type="email" autocomplete="email" required>

Every input needs a <label>. The right type gives phones the right keyboard, and autocomplete lets browsers fill in saved details.

Images and media

Write alt text that describes what a meaningful image shows. Use alt="" for decorative images. Wrap an image and its caption in <figure> and <figcaption>.

Small elements that help

  • <time datetime="2026-09-16"> for dates.
  • <address> for contact details.
  • <details> and <summary> for accordions that need no JavaScript.
  • lang="en" on the <html> element so screen readers use the right pronunciation.

Keep reading

HTML and CSS

CSS Grid vs Flexbox: When to Use Each

Flexbox lays out items in one direction; CSS Grid lays out rows and columns together. Real examples of navbars, card grids, and page layouts with each.

, 1 min read