Understanding Semantic HTML Tags: A Complete Beginner-Friendly Guide
When building web pages, HTML is not just about structureβitβs also about meaning .
This is where Semantic Tags come into play.
Semantic HTML helps both developers and browsers understand what each part of your webpage represents.
π§ What Are Semantic Tags?
Semantic tags clearly describe their meaning in a human- and machine-readable way.
Example:
<header> This is the header </header>
Enter fullscreen mode
Exit fullscreen mode
Instead of using:
<div> This is the header </div>
Enter fullscreen mode
Exit fullscreen mode
π The first example is better because <header> tells us the purpose directly.
β Non-Semantic vs β
Semantic
Non-Semantic:
<div> <div> Logo </div> <div> Menu </div> </div>
Enter fullscreen mode
Exit fullscreen mode
Semantic:
<header> <h1> Logo </h1> <nav> Menu </nav> </header>
Enter fullscreen mode
Exit fullscreen mode
π Semantic HTML improves:
Code readability
SEO
Accessibility
ποΈ Common Semanticβ¦