Lesson 2.6: Semantic HTML (header, footer, nav, section, article)
1. What is Semantic HTML?
-
Semantic HTML means using HTML elements that clearly describe their meaning and purpose in a web page.
-
Instead of just using
<div>everywhere, semantic tags tell both browsers and developers what type of content is inside. -
This improves readability, accessibility (for screen readers), and SEO (Search Engine Optimization).
2. Why Semantic HTML is Important?
-
Better Accessibility – Screen readers and assistive technologies can interpret content more accurately.
-
SEO Friendly – Search engines understand the structure of your page and rank it better.
-
Code Readability – Easier for developers to read and maintain.
-
Future-Proof – Modern browsers optimize semantic tags for better performance.
3. Common Semantic Elements
3.1 <header>
-
Represents the introductory content of a page or a section.
-
Often contains the website logo, title, and navigation menu.
3.2 <footer>
-
Represents the bottom part of a page or section.
-
Usually contains copyright, contact info, social media links.
3.3 <nav>
-
Represents a navigation section of a website.
-
Contains links to main pages or sections.
3.4 <section>
-
Defines a thematic grouping of content.
-
Example: news articles, product details, services.
3.5 <article>
-
Represents independent, self-contained content.
-
Example: blog post, news article, forum post.
4. Example – Putting It All Together
5. Best Practices
✔ Use semantic elements instead of <div> whenever possible.
✔ Do not misuse tags (e.g., don’t use <footer> inside <header>).
✔ Combine semantic tags with CSS for styling and JavaScript for interactivity.
✔ Keep sections meaningful and structured.
