HTML2 min read
Semantic HTML: Stop Using Divs for Everything
The right elements for accessibility and SEO
S
Shahar Amir
Semantic HTML: Stop Using Divs for Everything
Divs tell browsers nothing. Semantic elements tell them everything.
Why It Matters
- Screen readers understand your page structure
- SEO improves when Google knows what's what
- Maintainability — code explains itself
The Main Structure
html
1234567891011
<!-- ❌ Div soup --><div class="header">...</div><div class="nav">...</div><div class="main">...</div><div class="footer">...</div>
<!-- ✅ Semantic HTML --><header>...</header><nav>...</nav><main>...</main><footer>...</footer>Article vs Section vs Div
html
1234567891011121314151617
<!-- article: Self-contained, could be extracted --><article> <h2>Blog Post Title</h2> <p>Content that makes sense on its own...</p></article>
<!-- section: Thematic grouping with heading --><section> <h2>Features</h2> <p>Content about features...</p></section>
<!-- div: No semantic meaning, just styling --><div class="card-grid"> <article>...</article> <article>...</article></div>Navigation
html
1234567891011121314
<nav aria-label="Main"> <ul> <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> </ul></nav>
<nav aria-label="Breadcrumb"> <ol> <li><a href="/">Home</a></li> <li><a href="/blog">Blog</a></li> <li aria-current="page">This Post</li> </ol></nav>Interactive Elements
html
1234567891011
<!-- ❌ Fake button --><div class="button" onclick="submit()">Submit</div>
<!-- ✅ Real button --><button type="submit">Submit</button>
<!-- ❌ Fake link --><span class="link" onclick="navigate()">Click here</span>
<!-- ✅ Real link --><a href="/page">Click here</a>Figure & Figcaption
html
123456789
<figure> <img src="chart.png" alt="Sales growth chart"> <figcaption>Q4 2025 sales increased by 40%</figcaption></figure>
<figure> <pre><code>const x = 1;</code></pre> <figcaption>Variable declaration in JavaScript</figcaption></figure>Time Element
html
123
<p>Posted on <time datetime="2026-01-29">January 29, 2026</time></p>
<p>Event starts at <time datetime="14:30">2:30 PM</time></p>Quick Reference
| Element | Use for |
|---|---|
| ` | Page or section header |
| ` | Navigation links |
| ` | Main content (one per page) |
| ` | Self-contained content |
| ` | Thematic grouping |
| ` | Sidebar, callouts |
| ` | Page or section footer |
| ` | Images, code, diagrams |
| ` | Dates and times |
The Rule
If an element has semantic meaning, use the semantic tag. Use only for styling containers with no meaning.
#semantic#accessibility#seo
Stay Updated 📬
Get the latest tips and tutorials delivered to your inbox. No spam, unsubscribe anytime.