Semantic HTML
Semantic HTML uses elements according to their defined meaning so browsers and other tools can understand content structure and behavior.
Download Markdown (.md)Soroush’s Product Wiki · https://wiki.soroush.uk/topic/semantic-html/
01What 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.[1][2]
CSS changes presentation and JavaScript enhances behavior without erasing native semantics, keyboard support, or no-script usefulness.
02Why 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.
03When 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.
04How it works
- Identify the content structure, relationships, and interaction purpose before styling.
- Choose the native element whose defined semantics match that purpose.
- Provide names, labels, heading order, and form relationships in markup.
- Layer CSS for presentation and JavaScript for enhancement without removing native behavior.
- Validate markup and test keyboard, accessibility-tree, no-script, and real assistive-technology behavior.
05A 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.
06Where 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.
07Sources
- HTML Standard: Semantics, Structure, and APIs of HTML DocumentsWHATWG · Living web standardHTML Standard: Semantics, Structure, and APIs of HTML Documents
- HTML: A Good Basis for AccessibilityMDN Web Docs · Official technical documentationHTML: A Good Basis for Accessibility