Html5 Semantic
Semantic HTML5 elements such as <header> , <nav> , <main> , <article> , and <footer> describe the meaning of each region of a page, giving browsers, search engines, and screen readers a real document structure instead of anonymous <div> wrappers.
Learn Python, JavaScript, Java and more with free interactive lessons, real projects and AI-powered help. Beginner-friendly.
Part of the free HTML & CSS course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
", " with ", " with ", ], answer: 0, explanation: " wraps the illustration and provides a programmatically linked caption.", }, , ]; const faqItems = [ , , , , , , ]; const HTML5SemanticLesson = () => { const = useAuth(); const = useProgress('html-css'); useEffect(() => { document.title = "Advanced HTML5 Semantic Architecture | HTML & CSS Course | LearnCodingFast"; if (user) return () => ; }, [user, markLessonViewed]); return ( Courses / HTML & CSS / HTML5 Semantic Architecture Back to Course Lesson 16 • Advanced Track
By the end of this lesson you'll be able to replace generic div soup with meaningful HTML5 elements that give your page a real document outline — making it easier for search engines to index and for screen-reader users to navigate.
A web page is like a newspaper. It has a masthead at the top ( header ), a table of contents linking sections ( nav ), the main story area ( main ) full of individual articles ( article ), a sidebar of related snippets ( aside ), and the fine print at the bottom ( footer ).
Now imagine a newspaper printed entirely in one font, with no headlines, columns, or boxes — just an undifferentiated wall of text. That is what a page of nothing but div s looks like to a screen reader or a search engine: every box says "I am a box" and nothing more. Semantic elements are the headlines and column rules that let a machine read your page the way a person reads a paper.
A semantic element is a tag whose name describes the meaning of its content, not how it looks. Most of them render as a plain block box — visually identical to a div — but each one carries a built-in landmark role that browsers, search engines, and screen readers can act on. Here is the core set you will reach for on almost every page.
Run the worked example below. Notice that every landmark is just a labelled box — but a screen-reader user can jump straight to "main" or "navigation" because of those labels, something impossible with bare div s.
This is the pairing that trips everyone up. The deciding question is simple: would this content still make sense lifted out of the page and published on its own? If yes — a blog post, a news item, a product card, a comment — it is an article . If it is just one labelled part of a bigger whole — a chapter, a "Features" block, a tab panel — it is a section .
A second rule helps too: a section should always have a heading ( h2 – h6 ). If a chunk has no natural heading and is only there for layout, you probably want a plain div instead. They can also nest: an article can contain section s, and a section can contain article s.
Semantics are not only about page-level landmarks; smaller elements add meaning inside your content too:
"Div soup" is markup where every region is a div with a class — div class="header" , div class="nav" — that looks right but means nothing to a machine. The classes are for you ; the elements should be for everyone else . Swapping each wrapper for the matching landmark is usually a one-for-one rename, and it instantly gives you the document outline below.
The page below works visually but is pure div soup. Replace each labelled div with the matching semantic element. Fill in the blanks marked ___ , then run it and check the comments.
Finish this blog post so it uses content-level semantics: wrap it in an article , add a machine-readable date, highlight a key term, and caption the image. Fill in the blanks and verify against the comments.
Support is faded now — only an outline is given. Build a small but complete semantic page. Use the worked examples in sections 1 and 2 as your reference if you get stuck.
You can now architect pages with semantic HTML5 instead of div soup. The essentials:
Next up: Accessibility Deep Dive & ARIA , where you'll extend these landmarks with ARIA roles and attributes for richer, more dynamic interfaces.
Practice quiz
How many <main> elements should a single page have?
- Exactly one
- At least two
- As many as you like
- None
Answer: Exactly one. A page must have exactly one <main> landmark marking its unique primary content.
What is the key test for choosing <article> over <section>?
- Would the content still make sense if published on its own (e.g. in an RSS feed)?
- Does the content have any images?
- Is the content longer than one paragraph?
- Is the content near the top of the page?
Answer: Would the content still make sense if published on its own (e.g. in an RSS feed)?. If the content is self-contained and could be syndicated alone, it is an <article>.
What landmark role does the <nav> element expose?
- banner
- navigation
- contentinfo
- complementary
Answer: navigation. <nav> exposes the navigation landmark role.
Which element is intended for tangential content like a sidebar or related links?
- <section>
- <aside>
- <article>
- <figure>
Answer: <aside>. <aside> marks complementary, tangential content (the complementary landmark).
A <section> element should generally contain what?
- A heading (h2-h6) describing the thematic group
- Only images
- A single inline span
- Nothing — it must be empty
Answer: A heading (h2-h6) describing the thematic group. A section is a titled thematic region and should have a heading.
What does the datetime attribute on <time> provide?
- A tooltip shown on hover
- A machine-readable date/time value while the visible text can be friendlier
- An automatic countdown timer
- The user's local timezone
Answer: A machine-readable date/time value while the visible text can be friendlier. datetime gives a machine-readable value (e.g. 2026-06-09) while the text can read 'last Tuesday'.
What does the <mark> element semantically indicate?
- Text highlighted for relevance or noteworthiness
- A bookmark anchor
- Bold text only
- A required form field
Answer: Text highlighted for relevance or noteworthiness. <mark> means the text is noteworthy/relevant here, not merely visually yellow.
Which landmark role does <footer> expose at the page level?
- contentinfo
- banner
- main
- region
Answer: contentinfo. A page-level <footer> exposes the contentinfo landmark role.
Which element pairs a self-contained illustration with a caption tied to it?
- <figure> with <figcaption>
- <div> with <p>
- <picture> with <source>
- <aside> with <small>
Answer: <figure> with <figcaption>. <figure> wraps the illustration and <figcaption> provides a programmatically linked caption.
Do most semantic landmark elements come with significant default styling?
- Yes, they each have unique colors and borders
- No — they render as plain block boxes; their value is meaning, not appearance
- Yes, they are all inline by default
- They are invisible until styled with JavaScript
Answer: No — they render as plain block boxes; their value is meaning, not appearance. Landmarks like header, main, section render as plain blocks; the benefit is semantics, not looks.