0
0
HTMLmarkup~3 mins

Semantic vs non-semantic elements in HTML - When to Use Which

Choose your learning style9 modes available
The Big Idea

Discover how simple tags can make your website friendlier for everyone, including search engines and users with disabilities!

The Scenario

Imagine building a webpage by using only generic containers like <div> and <span> for everything, from headers to footers and articles.

The Problem

Without clear meaning, it's hard for browsers, search engines, and assistive tools to understand the page structure. This makes navigation confusing and accessibility poor.

The Solution

Semantic elements like <header>, <nav>, <article>, and <footer> give clear meaning to parts of the page, helping browsers and users understand the content better.

Before vs After
Before
<div class="header">Welcome</div>
<div class="nav">Menu</div>
After
<header>Welcome</header>
<nav>Menu</nav>
What It Enables

Using semantic elements makes your webpage easier to navigate, more accessible, and better understood by search engines.

Real Life Example

Screen readers can quickly jump between sections like navigation and main content when semantic tags are used, improving the experience for visually impaired users.

Key Takeaways

Semantic elements describe the purpose of content clearly.

They improve accessibility and SEO.

They make your code easier to read and maintain.