Understanding Semantics
Semantic HTML uses tags that clearly define a structure and meaning in human-readable way. Elements like `
- Clarity for developers and browsers
- Improved accessibility for screen readers
- Stronger SEO with meaningful markup
Semantic vs Non-Semantic
Non-semantic: <div class="navbar">...</div> Semantic: <nav>...</nav>
Semantic Element Gallery
Represents the main content area of the page.
Self-contained composition like a blog post or product listing.
Defines a standalone section of a document typically with a heading.
Navigation links for the website or section.
Supplementary content like sidebars or pull quotes.
Page or section footer with metadata or related links.
Semantic Code Example
<!DOCTYPE html> <html> <head> <title>Semantic Layout</title> </head> <body> <header>Site Header</header> <nav>Menu</nav> <main> <article>Blog post</article> <aside>Related links</aside> </main> <footer>Site Footer</footer> </body> </html>
Non-Semantic vs Semantic
Non-Semantic Example
<div id="nav">Menu</div> <div class="content"> <div class="post">Blog</div> </div>
Harder to maintain and less accessible.
Semantic Example
<nav>Menu</nav> <main> <article>Blog</article> </main>
Clear structure and better SEO value.