HTML: HTML Semantics

Last updated: 2026-09-08

Semantic tags give meaning to your web page structure — they tell the browser not just how to display something, but also "what this section is." This greatly helps with SEO, accessibility, and code readability.

Tags in this section: <div> <header> <nav> <main> <section> <article> <aside> <footer> <figure> <figcaption> <time> <mark> <details> <summary> <blockquote> <code> <address> <dialog> <span>

1. What Is Semantics

"Semantics" means "meaning." You can build any layout with <div>, but the browser can't understand the container's purpose. Semantic tags communicate their purpose directly through their names:

▶ Example

▶ Try it Yourself
📌 Common Tags:<header> page header, <nav> navigation, <main> main content, <section> section, <article> article, <aside> sidebar, <footer> footer. They are all block-level containers that function like <div>, but their names describe their purpose.


2. Benefits of Semantics

Semantics offer three direct benefits: search engines understand your page structure more accurately; screen readers can jump to specific areas; developers understand the layout at a glance, without guessing what a <div> class name means.


3. Image/Content Container: <figure> and <figcaption>

<figure> wraps self-contained content like images, code blocks, or charts, while <figcaption> provides a caption for it:

▶ Example

▶ Try it Yourself

4. Time and Highlighting: <time> and <mark>

<time> makes dates and times machine-readable, and <mark> highlights search keywords or important text:

▶ Example

▶ Try it Yourself

5. Collapsible Content: <details>and <summary>

<details> creates an expandable/collapsible interactive widget, and <summary> defines its visible heading. Pure HTML, no JavaScript needed:

▶ Example

▶ Try it Yourself
💡 More Semantic Tags:<blockquote> for quotes, <code> for code, <address> for contact info, <dialog> for dialogs. Everything can be semantic — find the most fitting tag before using a generic one.

Tags in this section: <div> <header> <nav> <main> <section> <article> <aside> <footer> <figure> <figcaption> <time> <mark> <details> <summary> <blockquote> <code> <address> <dialog> <span>

❓ FAQ

Q How do semantic tags affect SEO?
A Search engines use semantic tags to understand page structure and content importance. <header> tells search engines "this is the page header," <main> indicates "this is core content," <article> means "this is a standalone article." Search engines give higher weight to content inside <main> and <article>. Additionally, semantic tags help search engines generate more accurate result snippets (displaying article titles, authors, publish dates).
Q What's the difference between <section> and <article>?
A <article> is independent, complete content that can be published or reused on its own (like blog posts, news articles, reviews). <section> is a thematic grouping of content, typically with a heading, but isn't standalone (like chapters, tab panels, product features). The test: if the content block makes sense on its own, use <article>; if it needs context to be understood, use <section>.
Q When should I use <div>?
A Use <div> only when no suitable semantic tag exists. Common scenarios: 1) Pure styling containers (wrapping elements for Flexbox layout); 2) JavaScript hooks (modals, popups); 3) Groupings with no semantic meaning. Rule: first look for semantic tags (header/nav/main/section/article/aside/footer), fall back to div when none fit.
Q How is <details> and <summary> browser compatibility?
A <details> and <summary> are HTML5 native collapsible panels, supported by all modern browsers (Chrome, Firefox, Safari, Edge) — excellent compatibility. Benefits: collapsible without JavaScript, supports keyboard navigation and screen readers. Limitations: limited styling customization (like arrow icons), complex interactions still need JavaScript. IE doesn't support it, but IE is discontinued — no need to worry.

📖 Summary

📝 Exercises

  1. Build a Skeleton: Use semantic tags to build a blog page structure and fill in some placeholder text.
  2. Compare the Experience: Use a screen reader to navigate a pure <div> page and a semantic page side by side, and observe the difference.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏