Semantic HTML: Choose Elements by Meaning
Meaning before appearance
Semantic HTML describes the purpose of content using elements that match it. A heading identifies a topic; a paragraph holds prose. A browser can expose those meanings to accessibility tools even when the visual style changes. A generic div does not convey a heading merely because its text is large.
<h1>Garden journal</h1><p>The first seedlings appeared today.</p>A page heading introduces a paragraph.
Choose the element for the task
A list groups related items and a link points to a destination. Use the native element before adding extra roles. These structures give browsers useful information without custom scripting. A link needs an href to function as a hyperlink.
<h2>Resources</h2><ul> <li> <a href="https://example.com/guide">Planting guide</a> </li> <li>Seed calendar</li></ul>The list has two items; the first contains a hyperlink.
Use generic containers when appropriate
A div groups flow content when no more specific element fits. A span groups inline text. A class can be a styling hook but does not add a semantic role. Keep meaningful elements inside these containers rather than replacing them.
<div class="card"> <h2>Workshop</h2> <p> Room <span class="room">B</span> </p></div>The container groups a heading and paragraph; the room letter remains inline.
Common mistakes and practice
Do not choose elements by their default font size. Semantics alone do not guarantee accessibility: check link names, logical order and keyboard access. Practice by replacing a generic title and list with native elements.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Semantic HTML: Choose Elements by Meaning — Knowledge Check
Apply the semantic HTML and page structure concepts from this lesson.
Which markup identifies a page topic?
What does class="card" add to a div?
Which element groups items whose order is not significant?
Which approach best represents an actual navigation link?
Why choose semantic markup even when two elements look alike?