HTML Semantics
HTML Semantics: Writing Markup That Describes Its Meaning
Semantic HTML uses descriptive tag names—such as article, nav, main, and button—that explain the role of their content rather than relying solely on generic div and span containers. Both search engine crawlers and screen readers depend on semantic tags to understand page structure accurately.
Key Semantic HTML5 Elements
Replace repetitive generic wrappers with landmarks and content tags that match the content's purpose:
headerandnav: Identify site branding and primary navigation links.main: Marks the central unique content of the document so keyboard users can skip repeated menus.article: Wraps standalone, reusable pieces like blog posts, forum threads, or product cards.section: Groups thematic chapters inside a page, paired with a heading (h2orh3).aside: Holds supporting sidebars, author notes, or callout boxes.figure,figcaption, andtime: Pair media with captions and machine-readable ISO dates (datetime="2026-11-12").
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Semantic HTML5 Article</title>
</head>
<body>
<header>
<nav aria-label="Main Menu"><a href="/blog">Engineering Blog</a></nav>
</header>
<main>
<article>
<header>
<h1>Why Semantic HTML Matters</h1>
<p>Published <time datetime="2026-11-12">November 12, 2026</time></p>
</header>
<section>
<h2>Screen Reader Navigation</h2>
<p>Assistive tools list landmarks and headings so visitors jump straight to answers.</p>
</section>
<footer><p>Tags: HTML5, Accessibility</p></footer>
</article>
</main>
<footer><p>© 2026 KoderSolution</p></footer>
</body>
</html>
Common Mistakes to Avoid
- Using
div onclick="..."instead ofbutton: Fake clickabledivtags miss keyboard Enter/Space activation and focusability automatically provided bybutton. - Wrapping a whole page in
sectionwhendivis meant: Reservesectionfor meaningful thematic regions that usually carry a heading. - Adding redundant ARIA roles onto native semantic tags: Adding
role="navigation"to anavtag is unnecessary becausenavalready carries that implicit role.
Frequently Asked Questions
Does semantic HTML directly improve SEO?
Yes. Clear landmark and heading tags help crawlers identify primary article copy versus boilerplate sidebars and footers.
When is it still okay to use a div or span?
Use div and span purely as styling or layout hooks (such as Flex/Grid wrapper containers) when no semantic tag describes the group.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Try it Yourself
Experiment with the code from this lesson in our interactive playground.