Loading...
Loading...
Use meaningful HTML elements that describe their content for better accessibility and SEO
Semantic HTML means using tags that describe the meaning of their content, not just how it looks. Instead of wrapping everything in Create a semantic HTML page with: ` paragraphs, , , , and more.
Non-Semantic vs Semantic
<!-- ā Non-semantic: lots of <div>s with classes -->
<div class="header">
<div class="nav">...</div>
</div>
<div class="main">
<div class="article">...</div>
</div>
<div class="footer">...</div>
<!-- ā
Semantic: meaningful elements -->
<header>
<nav>...</nav>
</header>
<main>
<article>...</article>
</main>
<footer>...</footer>
Semantic Elements Reference
Element What it's for ` Introductory content ā logo, nav, heading ` Navigation links ` The page's main content (use once per page) ` Self-contained content (blog post, news story) ` A thematic group of content ` Sidebar content, tangentially related ` Footer ā copyright, links, author info ` An image, diagram, or code block with caption ` Caption for the ` ` A date or time ā great for blogs
Example: A Blog Page
<body>
<header>
<h1>My Coding Blog</h1>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/contact">Contact</a>
</nav>
</header>
<main>
<article>
<header>
<h2>Learning HTML</h2>
<time datetime="2026-01-15">Jan 15, 2026</time>
</header>
<p>Today I learned about semantic HTML...</p>
<aside>
<h3>Related Topics</h3>
<ul>
<li>CSS Grid</li>
<li>Flexbox</li>
</ul>
</aside>
</article>
</main>
<footer>
<p>© 2026 My Blog</p>
</footer>
</body>
Why Use Semantic HTML?
Common Mistakes
ā Wrong Why ā
Right ` Generic div provides no meaning Use ` Multiple ` ` Only one ` ` ` A single link can just be an `` tag Empty semantic elements If there's no navigation, don't use ` Only use semantic elements when they make sense
Your Turn!
` title and `
` heading and 2 `
š”Need a hint? (3 available)
šShow solution (try it yourself first!)
<header>
<h1>My Coding Journey</h1>
<nav>
<a href="/">Home</a>
<a href="/projects">Projects</a>
<a href="/contact">Contact</a>
</nav>
</header>
<main>
<article>
<h2>Why I Started Learning HTML</h2>
<p>I wanted to build websites and share my ideas with the world.</p>
<p>Semantic HTML makes my pages accessible and SEO-friendly.</p>
</article>
</main>
<footer>
<p>© 2026 My Coding Journey</p>
</footer>