Loading content…
Loading content…
Write meaningful HTML that's accessible, SEO-friendly, and maintainable
<button> instead of <div onclick=""> allows users with assistive technology to navigate properly.<header>, <nav>, and <article> tell search engines what's important.Senior Developer Wisdom
<header>
<h1>My Website</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h2>Blog Post Title</h2>
<p>Content here...</p>
</article>
<aside>
<h3>Sidebar</h3>
<p>Related content...</p>
</aside>
</main>
<footer>
<p>© 2026 My Company</p>
</footer>
<!-- Article: self-contained content -->
<article>
<h2>Article Title</h2>
<p>Article content...</p>
</article>
<!-- Section: thematic grouping -->
<section>
<h2>Section Title</h2>
<p>Content grouped by theme...</p>
</section>
<!-- Figure: images with captions -->
<figure>
<img src="chart.png" alt="Sales data">
<figcaption>Q1 Sales Performance</figcaption>
</figure>
Common Pitfall
<div> when a semantic element exists. <div> has no meaning. If content is an article, use <article>. If it's a navigation, use <nav>.<form>
<fieldset>
<legend>Personal Information</legend>
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</fieldset>
<button type="submit">Submit</button>
</form>
<label> with form inputs using the for attribute.<details>
<summary>Click to expand</summary>
<p>This content is hidden until expanded.</p>
</details>
<menu>
<li><button>Action 1</button></li>
<li><button>Action 2</button></li>
</menu>
<div class="header">
<div class="nav">
<div class="nav-item"><a href="/">Home</a></div>
</div>
</div>
<header>
<nav>
<ul>
<li><a href="/">Home</a></li>
</ul>
</nav>
</header>
Pro Tip
| Element | Purpose |
|---|---|
<header> | Introductory content or site navigation |
<nav> | Navigation links |
<main> | Main content of the page |
<article> | Self-contained content (blog post, news) |
<section> | Thematic grouping of content |
<aside> | Tangential content (sidebar) |
<footer> | Footer content |
<figure> | Images, diagrams with captions |
<details> | Expandable/collapsible content |
Semantic HTML Checklist
Marking it complete updates your roadmap progress percentage.