Semantic HTML5 Elements
Writing semantic HTML means choosing tags that clearly describe their meaning to both the browser and developer, rather than filling pages with generic divs.
What is it?
Semantic elements clearly convey their purpose. Examples include `<header>`, `<nav>`, `<main>`, `<article>`, `<section>`, `<aside>`, and `<footer>`.
Why is it used?
Semantic HTML dramatically improves SEO ranking, accessibility for screen readers used by visually impaired users, and codebase maintainability.
Detailed Explanation
Syntax Structure
<body>
<header>...</header>
<nav>...</nav>
<main>
<article>
<section>...</section>
</article>
<aside>...</aside>
</main>
<footer>...</footer>
</body>
Code Example
<header>
<h1>IGM Computer Institute</h1>
<nav aria-label="Main Navigation">
<a href="/">Home</a>
<a href="/courses">Courses</a>
<a href="/tutorial">Tutorials</a>
</nav>
</header>
<main>
<article>
<h2>Why Learn Python in 2026?</h2>
<p>Python continues to dominate AI, Machine Learning, and backend development.</p>
</article>
<aside>
<h3>Upcoming Batches</h3>
<p>Next KLiC Python batch starts on Monday.</p>
</aside>
</main>
<footer>
<p>© 2026 IGM Computer Institute. All rights reserved.</p>
</footer>
Explanation of the Code
Expected Output
Real-World Application
Google penalizes non-semantic 'div-soup' websites in search ranking algorithms in favor of accessible semantic structures.
Common Mistakes to Avoid
Quick Practice Challenge
Refactor a page layout using `<header>`, `<nav>`, `<main>`, `<section>`, and `<footer>`.