HTML5 Semantic
Semantic HTML means choosing elements that describe what content is, not just how it should look. HTML5 added a set of structural elements such as header, nav, main, article, section, aside and footer. They look exactly like a div by default, but they tell browsers, screen readers and search engines what role each part of the page plays.
The main structural elements
<header>holds introductory content for the page or for a section, such as a logo, a title or a byline.<nav>wraps a major block of navigation links, like the main menu or a table of contents.<main>contains the central content of the page. Use only one visiblemainper page.<article>is a self-contained piece that would make sense on its own, such as a blog post, a product card or a comment.<section>groups related content under a common heading, like chapters of a long page.<aside>holds content related to the surroundings but not essential, such as a sidebar or a pull quote.<footer>closes a page or section with copyright, contact details or related links.
A page laid out with semantic tags
<body>
<header>
<a href="/">Food Notes</a>
<nav aria-label="Main">
<ul>
<li><a href="/recipes">Recipes</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h1>Masala Chai at Home</h1>
<p>Ready in <time datetime="PT15M">15 minutes</time></p>
<section>
<h2>Ingredients</h2>
<p>Tea leaves, milk, ginger, cardamom.</p>
</section>
<figure>
<img src="chai.jpg" alt="Cup of chai with spices">
<figcaption>Serve hot.</figcaption>
</figure>
</article>
<aside>Try it with fresh mint.</aside>
</main>
<footer><p>Contact: hello@example.com</p></footer>
</body>
Who benefits from semantic markup
Screen reader users can jump directly between landmarks, such as straight to the navigation or the main content, instead of listening to the page from the top. Search engines get clearer signals about which part is the actual content and which is repeated chrome. Other developers can read your code more easily, because <nav> explains itself while <div class="nav-wrap-2"> does not. Browser reader modes also rely on these elements to find the article text.
Smaller semantic elements
Semantics also apply at the text level. <time datetime="..."> gives dates a machine-readable value, <figure> with <figcaption> ties a caption to an image, <mark> highlights relevant text, and <strong> and <em> express importance and emphasis rather than plain bold or italic styling.
Headings complete the picture. Start the main content with a single h1 and nest h2 and h3 in order without skipping levels, so the outline makes sense to anyone navigating by headings.
Section versus div, and other misuses
A frequent mistake is replacing every div with section. A section should have a heading and represent a meaningful part of the outline. If you only need a box for styling or layout, a div is still correct. Similarly, not every group of links needs nav; a few links in a footer can stay as a plain list.
Another misconception is that header must appear only once. It can appear inside each article or section as well, while main should not.
Key ideas
Pick the element that names the content's role, give sections headings, keep a single main, and fall back to div whenever no semantic element fits.
Ready to master real-world web development?
Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.