HTML course menu
Semantic HTML: What It Is and Why It Matters
Learn what semantic HTML means, why choosing elements by meaning improves accessibility, SEO and maintainability, how to replace div soup with meaningful elements, and a quick guide to picking the right element.
On this page
Semantic HTML means choosing elements for what content is, not for how it should look. A heading is an <h2>, a list is a <ul>, a button is a <button>, and navigation is a <nav>. CSS then takes care of the appearance.
Two versions of the same thing#
Both of these can be styled to look identical:
<!-- Non-semantic -->
<div class="top">
<div class="title">My Blog</div>
<div class="links">
<span onclick="go('/')">Home</span>
<span onclick="go('/about')">About</span>
</div>
</div>
<!-- Semantic -->
<header>
<h1>My Blog</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
</header>The second version tells the browser, search engines and assistive technology that this is the page header, that "My Blog" is the main heading, and that the links are navigation. The first version tells them nothing, and its "links" do not even work with a keyboard.
Why it matters#
Choosing the right element#
The layout elements are explained with a full example in Page Layout Elements.
Semantics is about meaning, not looks#
- Do not choose
<h3>because you like its size; restyle the correct heading with CSS. - Do not use
<blockquote>to indent text that is not a quotation; use CSSmargin. - Do not use
<table>to place things in columns; use CSS Grid or Flexbox.
Practice#
Practice exercise
Rewrite this non-semantic snippet using meaningful elements:
<div class="post">
<div class="post-title">Learning HTML in 30 days</div>
<div class="date">12 Oct 2026</div>
<div>Day one was all about elements and tags.</div>
<div class="btn" onclick="like()">Like</div>
</div>Show solution
<article class="post">
<h2>Learning HTML in 30 days</h2>
<p><time datetime="2026-10-12">12 Oct 2026</time></p>
<p>Day one was all about elements and tags.</p>
<button type="button">Like</button>
</article>A blog post is self-contained, so it is an <article>; its title is a heading; the date is a <time>; the text is a paragraph; and the "Like" control performs an action, so it is a <button>. (The like behaviour itself would be added with JavaScript.)
Key takeaway#
Finished this lesson?