Semantic HTML: Why It Matters
Pre-Work
As you watch the video above you may reference the following resources**:**
🎶 Essential HTML Elements Documentation:
- đź”— Heading Elements - The six levels of section headings for structuring your content hierarchy
- đź”— Line Break - When and why you should (rarely) use line breaks
- đź”— Contact Address - Semantic element for contact information
- đź”— Content Division - The generic container element and when to use it
- đź”— Content Span - Inline generic container for styling hooks
- đź”— Navigation Section - Semantic element for navigation links
- đź”— Generic Section - Thematic groupings of content
- đź”— Main Content - The primary content area of your document
- đź”— Header Element - Introductory content and navigation aids
- đź”— Footer Element - Footer information for sections or pages
- đź”— Aside Element - Content tangentially related to the main content
- đź”— Bring Attention To - Stylistically offset text without extra importance
- đź”— Strong Importance - Text with strong importance or urgency
- đź”— Article Contents - Self-contained, distributable content
- đź”— Emphasis - Stressed emphasis in text
- đź”— Idiomatic Text - Text in an alternate voice or mood
🎶 These references will help you understand the semantic meaning and proper usage of each element as you learn to write more meaningful HTML!
Introduction
- Icebreaker: Have you ever used a heading tag just to make text bigger? Or stacked a bunch of
<br>tags to add space? - Real-world scenario: Imagine a visually impaired user navigating your site with a screen reader. Semantic HTML makes their experience possible—and better for everyone.
- Lesson objectives:
- Understand what semantic HTML is and why it matters
- Identify common mistakes and how to avoid them
- Practice writing clean, accessible HTML
- Introduction to the concept:
- Semantic HTML uses tags that describe their meaning and role in the document (e.g.,
<header>,<nav>,<main>,<section>,<article>,<footer>). - This helps browsers, search engines, and assistive technologies understand your content.
- Semantic HTML uses tags that describe their meaning and role in the document (e.g.,
Core Concept Overview
- Key terms: semantic, accessibility, landmark elements, structure
- Analogy: Think of semantic HTML as labeling rooms in a house—"kitchen," "bedroom," "bathroom"—so everyone knows what each space is for.
- Common mistakes:
- Using headings for size, not structure (multiple
<h1>, skipping levels) - Using
<br>for spacing - Overusing
<div>and<span>instead of semantic tags - Not using
<label>for form fields - Missing
alton images - Using
<table>for layout - Not using lists for list content
- Using headings for size, not structure (multiple
- Conceptual quiz:
- What is semantic HTML?
- Why is it important for accessibility?
- Which tag would you use for navigation links?
- What’s wrong with using
<br>for spacing? - Why should you avoid multiple
<h1>tags?
Hands-On Application
- Example:
<!-- Bad --> <div> <h1>About Us</h1> <br /><br /> <div>We are awesome!</div> </div> <!-- Good --> <main> <header><h1>About Us</h1></header> <section><p>We are awesome!</p></section> </main>
Troubleshooting & Best Practices
- Common challenges:
- Unsure which tag to use? Check MDN’s HTML element reference
- Don’t use headings for size—use CSS!
- Always use one
<h1>per page
- Best practices:
- Use semantic tags for structure
- Use CSS for presentation
- Test with a screen reader or accessibility tool
- Enhancement:
- Try using ARIA roles only if you can’t use a semantic tag
Wrap-Up & Assessment
-
Key takeaways:
- Semantic HTML is about meaning, not just appearance
- It’s essential for accessibility and maintainability
-
Advanced quiz:
- What’s the difference between
<section>and<article>? - Why is
<nav>important? - How does semantic HTML help SEO?
- What’s wrong with using
<table>for layout? - How do you make a form accessible?
- What’s the role of
<main>? - Why avoid multiple
<h1>tags? - When should you use
<aside>? - What’s the best way to add space between elements?
- How do you label a button for screen readers?
For the quiz, provide answers and explanations after the questions, with adequate reflection in well-formatted MD. How much of this information ℹ️ was new to you? How well did the pre-req course prepare you for this?
What did you learn from the video and/or is there anything that you found and explored on Mozilla's Developer Network (MDN) that you found particularly helpful?
- What’s the difference between
-
Hands-on assessment / Homework:
- Create any web page you like (a personal homepage, a favorite recipe, a blog post, etc.) using only semantic HTML. Do not add any styles yet! Focus on using the correct tags for structure and meaning.
- Just use GitHub Gist for this. You can even copy/paste some stuff that you have already done, but make sure to update it to be semantic, using various tags that we have discussed in this lesson.
- Share your Gist link in our class Teams channel.