HTML5 Semantics Seekhein
Semantic markup likhne se SEO aur accessibility dono improve hoti hain.
Semantic HTML ka matlab hai aise HTML tags use karna jinka naam hi unke purpose aur content ka meaning (arth) explain karta hai. Example: <nav> navigation ke liye, <article> standalone blog post ke liye, aur <footer> bottom credits ke liye.
Agar aapke kitchen ke sabhi dabbon par plain white tape laga ho bina kisi naam ke, toh namak dhoondhne ke liye har dabba kholna padega (ye <div> soup hai).
Lekin agar dabbe par saaf likha ho: "Namak", "Haldi", "Mirchi" (ye <header>, <main>, <footer> hai), toh koi bhi insaan ya blind chef bina kisi confusion ke sahi cheez nikal sakta hai!
Jab aap plain <div> use karte hain, toh browser aur Google crawler ko ye nahi pata chalta ki page ka main content kahan hai aur advertisements kahan hain. Semantic tags:
<article> ko priority deta hai.<main> content par jump kar sakte hain, bina 50 header links sune.<header>Logo aur Main Intro</header>
<nav>Site Navigation Links</nav>
<main>
<section>
<article>Independent Blog Post</article>
</section>
<aside>Sidebar / Related Links</aside>
</main>
<footer>Copyright & Social Links</footer>
<!DOCTYPE html>
<html lang="hi">
<head>
<title>My Tech Blog</title>
</head>
<body>
<header>
<h1>⚡ DevTech Blog</h1>
<nav>
<a href="/">Home</a> | <a href="/about">About</a>
</nav>
</header>
<main>
<article>
<h2>HTML5 Semantics Seekhein</h2>
<p>Semantic markup likhne se SEO aur accessibility dono improve hoti hain.</p>
</article>
<aside>
<h3>Trending Articles</h3>
<p>CSS Grid in 2026</p>
</aside>
</main>
<footer>
<p>© 2026 DevTech. All rights reserved.</p>
</footer>
</body>
</html>
Semantic markup likhne se SEO aur accessibility dono improve hoti hain.
<header>: Website ya article ka intro container.<nav>: Major navigation links ka group.<main>: Webpage ka unique, primary content (page me sirf ek hi <main> hona chahiye).<article>: Aisa content jo agar alag se kisi RSS feed ya news reader me share kiya jaye, tab bhi uska pura sense banta ho.<section>: Related content ka thematic grouping (jaise "Features", "Pricing", "Testimonials").<aside>: Secondary content jo main content se indirectly related ho (sidebar, ads, author bio).<footer>: Author, copyright, legal links ka container.Medium, Substack, aur Dev.to ke har blog page ka code inspect karein: unka article <article> tag me hota hai aur author bio <aside> me.
<div class="nav"> ke bajaye <nav> use karein. <div class="footer"> ke badle <footer> use karein.
Agar content standalone shareable hai (jaise tweet, blog post ya comment), toh <article> use karein. Agar sirf ek section hai page ka, toh <section>.
<main> element hona chahiye.<section> ke andar ek heading (<h2> ya <h3>) zaroor honi chahiye.Playground me ek semantic personal profile page banayein jisme header, nav, main, section aur footer hon.
Ek News portal ka layout banayein jisme ek Breaking News <header>, Top Story <article>, Related Stories <aside> aur Weather widget ho.
Answer: Non-semantic elements (e.g. <div>, <span>) browser ya developer ko unke content ke baare me koi information nahi dete. Semantic elements (e.g. <form>, <table>, <article>) apne naam se hi content ka meaning aur role clearly define karte hain.
header, nav, main, article, section, aside, footer.Haan! Ek blog list page par 10 articles ho sakte hain, aur har article ke andar comments bhi <article> tag me ho sakte hain.
Nahi! Pure styling ya grid containers ke liye <div> bilkul valid hai. Sirf content structure ke liye semantic tags use karne chahiye.
Nahi! Aap kisi <article> ke andar bhi uska apna <header> rakh sakte hain (jisme article title aur author date ho).
Semantic tags jaise <main> aur <nav> screen reader ke liye direct jump points banate hain jise "landmarks" kehte hain.
<time datetime="2026-09-12">12 September</time> machine-readable date format provide karta hai.
Semantic HTML refers to using HTML tags whose names clearly convey their purpose and the meaning of their content to both the browser and developer. For instance, <nav> designates navigation menus, <article> marks independent self-contained content, and <footer> contains footer metadata and copyright info.
If every jar in your kitchen is wrapped in plain blank tape with no label, you must open every single container to find the salt (that is the dreaded <div> soup).
However, when each container is distinctly marked: "Salt", "Turmeric", "Cumin" (corresponding to <header>, <main>, <footer>), anyone—including a visually impaired chef using braille labels—can locate exactly what they need instantly without confusion!
When you rely purely on generic <div> wrappers, search engines and assistive technologies cannot determine where primary editorial content begins or where secondary sidebars and ads reside. Semantic tags deliver:
<article> with priority over boilerplate navigation.<main>, skipping lengthy headers.<header>Logo, Branding & Main Nav</header>
<nav aria-label="Primary">Navigation Links</nav>
<main>
<section>
<article>Independent Post or Card</article>
</section>
<aside>Related Links / Sidebar</aside>
</main>
<footer>Copyright & Terms</footer>
<!-- Landmark Layout -->
<header>
<h1>Tech Horizons Blog</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/articles">Articles</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h2>Modern Web Development in 2026</h2>
<p>Semantic architecture is the cornerstone of high-performance web engineering.</p>
</article>
</main>
<footer>
<p>© 2026 Tech Horizons. All rights reserved.</p>
</footer>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Semantic Blog Post Layout</title>
<style>
body { font-family: system-ui, sans-serif; margin: 0; line-height: 1.6; color: #1e293b; background: #f8fafc; }
header { background: #0f172a; color: white; padding: 1.25rem 2rem; display: flex; justify-content: space-between; align-items: center; }
nav a { color: #cbd5e1; text-decoration: none; margin-left: 1.5rem; }
nav a:hover { color: #38bdf8; }
.layout-container { display: flex; max-width: 1100px; margin: 2rem auto; gap: 2rem; padding: 0 1rem; }
main { flex: 3; background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
aside { flex: 1; background: white; padding: 1.5rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); height: fit-content; }
footer { background: #0f172a; color: #94a3b8; text-align: center; padding: 1.5rem; margin-top: 3rem; }
figure { margin: 1.5rem 0; text-align: center; }
figure img { max-width: 100%; border-radius: 6px; }
figcaption { font-size: 0.85rem; color: #64748b; margin-top: 0.5rem; font-style: italic; }
</style>
</head>
<body>
<header>
<h2 style="margin:0;">CodeCraft News</h2>
<nav aria-label="Main Navigation">
<a href="#">Home</a>
<a href="#">Tutorials</a>
<a href="#">Podcast</a>
</nav>
</header>
<div class="layout-container">
<main>
<article>
<header>
<h1 style="color: #0f172a; margin-top:0;">Building Resilient Semantic Interfaces</h1>
<p style="color: #64748b; font-size: 0.9rem;">
Published on <time datetime="2026-09-12">September 12, 2026</time> by Alex Rivers
</p>
</header>
<section>
<h2>Why Meaning Precedes Appearance</h2>
<p>CSS dictates presentation, but semantic HTML delivers true document meaning to assistive devices.</p>
<figure>
<img src="https://images.unsplash.com/photo-1507238691740-187a5b1d37b8?w=800&auto=format&fit=crop&q=80" alt="Clean code editor on workspace desk">
<figcaption>Figure 1: Architectural clarity begins with clean semantic HTML tags.</figcaption>
</figure>
</section>
</article>
</main>
<aside aria-label="Sidebar Resources">
<h3 style="margin-top:0;">Featured Resources</h3>
<ul style="padding-left: 1.25rem; line-height: 1.8;">
<li><a href="#">WCAG 2.2 Guidelines</a></li>
<li><a href="#">HTML5 Specification</a></li>
<li><a href="#">Semantic Cheatsheet</a></li>
</ul>
</aside>
</div>
<footer>
<p>© 2026 CodeCraft Media. Engineered with semantic standards.</p>
</footer>
</body>
</html>
+-------------------------------------------------------------------+
| <header> + <nav> |
+-------------------------------------------------------------------+
| |
| <main> <aside> |
| +---------------------------------------+ +-------------+ |
| | <article> | | Sidebar | |
| | <header>Title + Author Meta</header>| | Related | |
| | <section>Content Body</section> | | Links | |
| | <figure>Image + <figcaption></figure>| | Ads | |
| | <footer>Tags + Share</footer> | +-------------+ |
| +---------------------------------------+ |
| |
+-------------------------------------------------------------------+
| <footer> |
+-------------------------------------------------------------------+
| Common Mistake | Why It Breaks | Correct Semantic Solution |
|---|---|---|
<div class="nav"> |
Screen readers cannot recognize navigation landmark; SEO crawlers miss link structure | Use native <nav> element |
Multiple <main> visible |
Violates HTML5 spec; confusing landmark tree for assistive tech | Only 1 visible <main> per document |
Using <section> as style container |
Sections must have semantic meaning and typically include a heading | Use generic <div> for layout styling |
<p>Author: Rahul</p> without <address> |
Misses author contact metadata indexing | Use <address> for author/contact details |
<main> per page: Never have multiple unhidden main containers.<section>: Always include an <h2> - <h6> inside a section to give it a title.<article> for syndicatable items: Blog posts, news items, product cards, or forum threads.<figure>: Pair diagrams, code snippets, or charts with <figcaption>.
Semantic tags are universally supported across 100% of modern browsers (Chrome, Edge, Firefox, Safari). In legacy browsers like IE8 and below, block elements had to be explicitly defined via CSS display: block, which is no longer needed today.
Take this broken markup snippet:
<div class="header"><div class="menu">Links</div></div> <div class="content"><div class="post">Story</div></div> <div class="bottom">2026</div>
Refactor it into proper HTML5 tags: <header>, <nav>, <main>, <article>, and <footer>.
Create an <article> representing a breaking news card that contains:
a <header> with headline and <time>, a <figure> with photo and <figcaption>, a summary paragraph, and a <footer> showing author contact in an <address> tag.
| Question | Standard Answer |
|---|---|
What is the difference between <section> and <article>? |
<article> is standalone and reusable (it makes sense on its own if republished elsewhere). <section> is a thematic grouping of content inside a document. |
Why shouldn't you replace all <div> tags with <section>? |
Because <section> has semantic significance and should generally possess a heading. Pure visual wrappers (flex/grid containers) should remain <div>. |
Can an <article> contain multiple <section> tags? |
Yes. A long article can be subdivided into multiple thematic sections (e.g., Intro, Methods, Results, Conclusion). |
header, nav, main, article, section, aside, footer.Yes! A blog list or news feed page can contain dozens of independent articles, and comments inside an article can also each be enclosed in an <article> tag.
No! Generic <div> elements are completely valid and recommended for purely visual styling, flex containers, and positioning. Avoid them only when representing semantic content regions.
No. An individual <article> or <section> can contain its own introductory <header> containing its title and metadata.
Semantic tags like <main>, <nav>, and <footer> generate navigation landmarks that screen reader users can jump between using single-key shortcuts.
<time datetime="2026-09-12">12 September</time> provides both a human-readable display and a standardized ISO machine-readable date for calendar exports and search bots.