CSS Box Model Explained Simply
Margin, padding, border, content — these four layers control everything. We’ll break down how the box model works and why understanding it changes everything about CSS layouts.
Read ArticleLearn why semantic elements matter more than you think. We’ll explore header, nav, article, and footer tags that make your code accessible and SEO-friendly.
Most web developers get started with HTML and think it’s all the same. A div here, a span there, and you’ve got a website, right? Not exactly. Semantic HTML is the difference between writing code that technically works and code that’s actually built right.
Here’s the thing — when you use semantic elements like
<header>
,
<nav>
, and
<article>
, you’re not just making your site prettier. You’re creating a
structure that screen readers understand. Search engines can
parse it better. And honestly? Your code becomes way easier to
maintain six months from now when you’re looking back at what
you built.
We’re going to walk through the major semantic elements, show you how they work, and explain why they matter for both accessibility and SEO. By the end, you’ll understand how to build pages that don’t just look good — they’re built to last.
Let’s start with the foundational elements you’ll use in almost every project. These five tags form the backbone of semantic HTML structure.
Wraps introductory content, navigation, logos, or site titles. It’s not the same as a heading tag — it’s a container for your page’s top section.
Contains navigation links. Not every link on a page goes here — only the main navigation menu. You can have multiple nav elements if you need different navigation sections.
Marks self-contained content like blog posts, news articles, or forum posts. Use this when your content could stand alone and still make sense.
Groups thematically related content. It’s not a layout tool — it’s a way to organize your content logically. Each section should have a heading.
Contains tangentially related content — sidebars, pull quotes, related links. The content here should be removable without breaking the main article.
Contains footer information — copyright, links, contact info. You’ll typically have one at the page level, but sections and articles can have their own footers too.
So how do you actually put these together? Let’s walk through what a real page structure looks like. You’re not going to use all of these on every page, but understanding the hierarchy helps you make better choices.
Your page typically opens with a
<header>
containing your logo, site title, and main
<nav>
. This tells browsers and assistive devices that this is
where the page begins.
Use
<main>
to wrap your primary content. This signals that everything
inside is the main point of the page. Screen readers jump
to this automatically.
Break your content into
<section>
or
<article>
elements. Each should have a heading. This creates a
logical outline of your page.
End with a
<footer>
containing copyright info, sitemap links, and contact
details. It’s the last thing browsers and readers
encounter.
This isn’t just about writing prettier code. Semantic HTML directly impacts how people experience your website and how search engines understand it.
When you use semantic elements, screen readers can navigate your page structure. They understand where the header ends, where the main content begins, and where to find the footer. Someone using a screen reader isn’t just getting text — they’re getting meaningful structure. That’s the difference between usable and frustrating.
Google and other search engines use semantic markup to
understand your content better. When you properly mark up
your article with
<article>
and
<header>
tags, search engines can extract the main content more
accurately. This helps with rankings and rich snippets in
search results.
Six months from now, when you’re back in this code, semantic HTML tells a story. You don’t have to guess whether that div is the navigation or a sidebar. The code is self-documenting. Plus, other developers can jump in faster because the structure is clear.
Semantic markup works better across different devices and browsers. Some older devices don’t support every modern feature, but semantic HTML is rock solid. Your content stays accessible everywhere.
Even experienced developers slip up with semantic HTML. Let’s look at the most common mistakes so you don’t fall into the same traps.
Yeah, divs are flexible. But wrapping your entire navigation
in a
<div>
when
<nav>
exists? That’s missing the point. Use the right element for
the job.
Don’t jump from an h1 straight to an h3. And don’t use h2s just because they look good in your CSS. Follow proper heading hierarchy — h1, then h2s, then h3s within those. This creates an outline that makes sense.
You get ONE
<main>
element per page. Not two, not three. One. This clearly
identifies your primary content to assistive technology.
These can nest, but think about it logically. An article is self-contained content. Sections inside an article should be chapters or major divisions of that content. Don’t nest arbitrarily.
Semantic HTML isn’t complicated. It’s not a special skill you
need to master. It’s about making intentional choices with your
markup. When you pick
<nav>
instead of a generic div, you’re telling the browser, search
engines, and assistive devices what that content is. That’s
powerful.
Start with your next project. Map out your page structure first. Where’s the header? What’s your main content? What goes in the footer? Then pick the right semantic elements for each part. It won’t feel natural at first — that’s normal. But after a few projects, you’ll stop thinking about it and just build properly by default.
The best part? Your future self will thank you when you come back to this code in six months. And your users — especially those relying on assistive technology — will have a better experience. That’s what semantic HTML is really about.
This article is provided for educational purposes to help you understand semantic HTML concepts and best practices. While we’ve covered current standards and recommendations, web standards evolve continuously. Always refer to official documentation from the W3C and WHATWG for the most up-to-date specifications. The code examples shown represent common patterns but may need adaptation based on your specific project requirements. We encourage you to test thoroughly across different browsers and assistive technologies to ensure your implementations work as intended for all users.