# Semantic HTML

Semantic HTML uses elements according to their defined meaning so browsers and other tools can understand content structure and behavior.

- Type: practice
- Domain: Experience & interface
- Level: Foundational
- Last reviewed: 2026-09-23
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/semantic-html/>)

## What it means

Semantic HTML is the practice of choosing HTML elements for their specified purpose and meaning rather than only their default appearance or convenience. Headings, landmarks, links, buttons, lists, forms, and tables communicate structure and behavior to browsers, assistive technologies, search systems, and developer tools.

## Why it matters

Native elements bring interoperable keyboard, form, navigation, and accessibility behavior with less custom code. Clear document structure improves resilience, maintenance, machine interpretation, and the experience when styles or scripts fail.

## When to use it

Use semantic HTML as the baseline for every web interface. Introduce generic div and span containers for grouping or styling when no meaningful element applies, and use ARIA to supplement—not unnecessarily replace—native semantics.

## How it works

1. Identify the content structure, relationships, and interaction purpose before styling.
2. Choose the native element whose defined semantics match that purpose.
3. Provide names, labels, heading order, and form relationships in markup.
4. Layer CSS for presentation and JavaScript for enhancement without removing native behavior.
5. Validate markup and test keyboard, accessibility-tree, no-script, and real assistive-technology behavior.

## A practical example

A design-system team replaces clickable divs with buttons and navigation links, connects labels to inputs, and uses headings for hierarchy. Keyboard and screen-reader behavior improves while event code becomes smaller.

## Where it breaks

HTML does not contain a purpose-built element for every application widget, and correct elements do not ensure clear content or usable flows. Browser and assistive-technology differences still require testing, especially for complex controls.

## Common mistakes

- Choosing elements for their default visual style instead of their meaning.
- Using a clickable div where a link or button supplies the required behavior.
- Adding redundant or conflicting ARIA roles to native elements.
- Using headings to resize text rather than represent document hierarchy.

## Visualization

[View the visualization on the website](<https://wiki.soroush.uk/topic/semantic-html/#visualization-semantic-html>)

## Sources

1. [HTML Standard: Semantics, Structure, and APIs of HTML Documents](<https://html.spec.whatwg.org/multipage/dom.html>) — WHATWG · Living web standard
2. [HTML: A Good Basis for Accessibility](<https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Accessibility/HTML>) — MDN Web Docs · Official technical documentation

## Related topics

- [Accessibility Tree](<https://wiki.soroush.uk/topic/accessibility-tree/>)
- [Accessibility](<https://wiki.soroush.uk/topic/accessibility/>)
- [Keyboard Accessibility](<https://wiki.soroush.uk/topic/keyboard-accessibility/>)
