HTML Semantic Elements
You already know div as a generic box and class/id as hooks on elements. Semantic elements go further: they name regions by meaning — banner, navigation, primary content, side note, footer — so people, search tools, and screen readers can map the page without guessing from CSS alone. A wall of anonymous divs can look identical after styling, yet the structure stays opaque. Landmarks make the outline readable in the HTML itself.
Meaning before boxes
CSS can turn any tag into a column or a bar. That flexibility is why beginners overuse div. Semantic tags do not replace layout skills; they document intent. When a region is major navigation, mark it nav. When a block is the unique main story of this URL, mark it main. When a card could stand alone as a post or news item, consider article. Use a plain div when you need a styling wrapper with no special landmark role.
Direct answer
Prefer landmarks such as header, nav, main, article, section, aside, and footer when their meaning matches the content. Keep one primary main per page for the dominant unique content. Nest carefully — nav inside header is common; stuffing the whole site inside one article is not. Semantics name roles; class and id still label hooks on top of those roles.
📊 Core landmarks
| Element | Typical meaning |
|---|---|
| header | Introductory or banner content for a page or section |
| nav | Major navigation links |
| main | Dominant unique content of this page |
| article | Independent composition (post, story, card that could stand alone) |
| section | Thematic grouping, usually with a heading |
| aside | Side note related to the surrounding content |
| footer | Closing content for a page or section |
A simple page skeleton
Start with the classic outline: banner and links at the top, unique content in main, closing info in footer. This is the backbone most multi-page sites share before you add articles or sidebars.
Simple semantic skeleton
html<body>
<header>
<h1>City Guide</h1>
<nav>
<a href="index.html">Home</a>
<a href="about.html">About</a>
</nav>
</header>
<main>
<h2>Welcome</h2>
<p>Explore the city with clear HTML structure.</p>
</main>
<footer>
<p>All rights reserved.</p>
</footer>
</body>
Reading the skeleton
headerholds the site title and often the primarynavnavwraps major links — not every random list of anchors must benavmainholds the unique content for this URL; keep one per pagefootercloses the page with copyright or secondary links- Headings still matter inside landmarks — they label the themes
- You can add
classoridon these tags when you need CSS or fragment hooks from earlier lessons
Article, section, and aside
Inside main, grow structure: an article for a self-contained piece, section for thematic chunks (ideally with headings), and aside for related notes that are not the primary narrative. The second demo shows a small news-style layout without inventing fake landmarks.
Article section and aside
html<main>
<article>
<h2>Weekend markets</h2>
<section>
<h3>Saturday</h3>
<p>Fresh fruit stalls open at 8:00.</p>
</section>
<section>
<h3>Sunday</h3>
<p>Craft vendors join the square.</p>
</section>
</article>
<aside>
<h2>Tip</h2>
<p>Arrive early for the best produce.</p>
</aside>
</main>
Reading article, section, and aside
articlegroups content that could make sense on its own- Each
sectionhas a heading that states its theme asideholds a tip related to the article, not a secondmain- Nesting stays inside one
main— do not add anothermainfor the sidebar - If a box is only for layout columns with no meaning, a
divmay still be fine - Mix freely with
class="card"orid="tip"when styling or jumping requires it
Choosing landmarks vs div
Ask: “Does this region have a standard role?” If yes, use the matching landmark. If you only need a flex/grid wrapper, keep div. Do not sprinkle section or article everywhere to “look semantic” — empty meaning is worse than an honest wrapper. One clear main, purposeful nav, and honest article/aside choices beat a decorative forest of tags.
Practice in your editor
- Rebuild a practice page with
header,nav,main, andfooter. - Put the unique page story only inside
main. - Add one
articlewith a heading and two short paragraphs. - Optionally add an
asidewith a related tip. - Confirm there is exactly one
mainin the file. - Replace a meaningless outer
divaround the banner withheaderif it fits. - Write one sentence explaining when you would still use
div. - Optional: add
id="top"onheaderand a fragment link from earlier id practice.
Easy mistakes
- Multiple
mainelements on one page - Using
sectionwith no heading or theme when a heading would clarify - Wrapping the entire site in one giant
article - Calling every link list
nav(reservenavfor major navigation) - Replacing every
divwith random landmarks that do not match meaning - Forgetting that
class/idstill work on semantic tags
Summary
- Semantic elements name meaning — not only visual boxes
- Core landmarks: header, nav, main, article, section, aside, footer
- Keep one primary
mainper page - Prefer a landmark when the role fits; keep
divfor anonymous wrappers - Nest carefully; do not fake semantics for decoration
- Next: combine these landmarks into fuller page layouts
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top