Semantic HTML and why it matters
The document from the last lesson has a body. This lesson names the regions inside it. A class can change the paint, and the element name still says what the region is.
Your console output appears here.
The logs came from the article, the heading, the main element, and the link. Renaming the article in the HTML changes the first log. The script did not choose the name.
+Go deeper
The element is the name
A div and a section can look identical. The div is a generic group with no role of its own. A names the job: header, nav, main, article, section, aside, footer, or button. A page made only of divs can look finished and still announce nothing but box after box.
Regions a page needs
header introduces a page or a section. nav is a block of links. main is the primary content, and a page should have one. article is a piece that would still make sense on its own, such as a note or a story. section is a thematic group, usually with its own heading. aside is related but off to the side, such as a sidebar. footer closes a page or a section. A link in nav is still an anchor with an href. The landmark is the element, not a class called nav.
Headings name sections
An h1 names the page or the article. The next heading in that section is an h2. Choosing h4 because it looks smaller skips levels. Size belongs in CSS later. The number is the outline.
| Tag | Role | How it is used |
|---|---|---|
| header | Introductory content | For the page, or for one section |
| nav | A block of navigation links | The links are still anchors |
| main | The primary content | One per page |
| article | A self-contained piece | A note or a story that could stand alone |
| section | A thematic group | Usually with its own heading |
| aside | Content beside the main idea | A sidebar or a pull quote |
| footer | Closing content | For the page, or for one section |
Buttons are not divs
A button is in the tab order and is announced as an action. A div with a click handler is not, unless you rebuild all of that yourself. Use the button, then style it.
Read the name, then paint
If you removed every style, the regions should still be obvious from the tags. The script in the sandbox prints those tags. It is checking the HTML, not inventing a role.
Guided challenge
Semantic HTML and why it matters
The HTML uses an article, not a class of card. Point the script at the article element so it can read the tag, the heading, main, and the article href.
Your console output appears here.
EXPECTED CONSOLE OUTPUT
article A self-contained article has-main #article
Hints 0/2
Use all hints or make 3 failed runs (0/3).
Free sandbox
Edit the HTML and CSS. The JavaScript tab can read the result. This draft is saved separately.
Your console output appears here.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 100 XP. You can always revisit it.