HTML Semantic Elements and Why They Matter
HTML, CSS and Webbeginnerbest-practices
Codevity Admin · 10/24/2026
Codevity Admin · 10/24/2026
A page built entirely from elements looks fine in a browser, but to a screen reader or a search engine it is an undifferentiated pile of boxes. Semantic elements say what each part of the page is, not just how it looks.
| Element | Use it for |
|---|---|
| introductory content for the page or a section, such as a logo and navigation | |
| a block of major navigation links | |
| the primary content. Use one per page | |
| a self-contained piece that would make sense on its own, such as a blog post or a comment | |
| a themed group of content, normally with its own heading | |
| content related to, but separate from, the main content, such as a sidebar | |
| closing information, such as copyright or links |
and are still correct when nothing semantic fits. Just do not reach for them first.
Use to to describe structure, not to pick a font size. Keep one per page and do not skip levels (an followed by an ). Screen reader users often jump from heading to heading to scan a page, so a clean outline is their table of contents. Control the look with CSS.
A performs an action on the page. An with an navigates somewhere. Choosing correctly gives you keyboard support and the right behavior for free.
divheadernavmainarticlesectionasidefooterdivspanh1h6h1h2h4buttonahrefaltalt=""<label for="email">id<html lang="en">mainnav<nav>div<body>
<header>
<a href="/" class="logo">Codevity</a>
<nav aria-label="Main">
<ul>
<li><a href="/articles">Articles</a></li>
<li><a href="/quizzes">Quizzes</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h1>Understanding LINQ</h1>
<p>...</p>
</article>
<aside>
<h2>Related quizzes</h2>
</aside>
</main>
<footer>
<p>© 2026 Codevity</p>
</footer>
</body><!-- Bad: no keyboard support, not announced as a button -->
<div class="btn" onclick="save()">Save</div>
<!-- Good: focusable, works with Enter and Space, announced correctly -->
<button type="button" onclick="save()">Save</button>