HTML Semantics
10 min read
What is HTML Semantics?
Semantic HTML uses meaningful tags like <header>, <nav>, <main>, <article>, <section>, and <footer> instead of generic <div> elements.
Syntax & Usage
The syntax and usage patterns for HTML Semantics follow standard HTML conventions. Below you will see code examples that demonstrate the most common use cases. Try modifying these examples in your own editor to experiment with different approaches.
Example
Here is a practical example demonstrating HTML Semantics:
Tips & Best Practices
- Always declare the document type with
<!DOCTYPE html> - Use semantic elements for better accessibility and SEO
- Always include
altattributes on images - Validate your HTML using the W3C Markup Validation Service
Summary
In this lesson you learned about HTML Semantics. Practice writing code to reinforce these concepts and move on to the next lesson when you feel comfortable.
Examples
html
<header>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
</header>
<main>
<article>
<h2>Article Title</h2>
<p>Article content...</p>
</article>
<aside>
<h3>Related Links</h3>
</aside>
</main>
<footer>
<p>© 2024 My Website</p>
</footer>
Test Your Knowledge
Take a quick quiz to check what you've learned in this lesson.