Document structure
HTML is a markup language: it labels pieces of a page, and it does not make decisions or do math. Every file has the same skeleton, with a head for facts about the page and a body for what a visitor sees. The example below is that skeleton.
Your console output appears here.
The console read the language, the charset, and the viewport element from the HTML you already had. Changing the script cannot add a missing head.
+Go deeper
The required shell
HTML does not run logic. It labels a piece of the page, and the browser decides how to draw that label. Most elements are an opening tag, the content, and a closing tag with a slash. A few, such as br, wrap nothing and have no closing tag. The page itself always starts with a doctype, then an html element, then head and body. The doctype is not a tag. It asks for modern HTML so the browser does not fall back to an old rendering mode. html is the root. head holds facts about the page, and nothing in it is drawn. body holds what a visitor sees.
What belongs in the head
Charset names the encoding. The title is the name of the document, used by the tab. Language belongs on the html element. The viewport meta element sets the layout width. width=device-width with initial-scale of 1 lays the page out at the device width. Leave it out and a phone may lay the page out very wide, then shrink it. None of these are paragraphs in the body.
Labels for the content
The body is a set of labels around the words. Headings, paragraphs, links, and generic boxes are enough for this document. Forms, data tables, and named regions come in the next lessons.
| Kind | Tags | What they are for |
|---|---|---|
| Headings | h1 through h6 | Section titles in order of importance. h1 is the most important on the page, not merely the biggest |
| Text | p, br, hr | A paragraph, one forced line break, or a horizontal divider |
| Emphasis | strong, em, b, i | strong and em mean important or emphasized. b and i are only a bold or italic look |
| Links and images | a, img | a href is a link. img src points at the file, and alt is the text if that file cannot be shown |
| Containers | div, span | Generic boxes with no meaning of their own. div groups a block of the page. span groups words inside a line |
| Lists | ul, ol, li, dl | ul is bullets, ol is numbers, li is one item, and dl pairs a term with its definition |
Lists that count
An ordered list starts at 1 unless you say otherwise. ol start="10" starts the count at 10. The reversed attribute counts backward, which fits a countdown or a ranking shown from the top. The number in front of each item is part of the list, not text you have to type yourself. Restyling that marker comes later, with CSS.
Read the head before the paint
Check doctype, lang, charset, viewport, and title before you restyle anything. The script reads those nodes. It does not create them.
Guided challenge
Document structure
The head already has a viewport meta element. The script still logs missing. Read that element and log viewport when it exists.
Your console output appears here.
EXPECTED CONSOLE OUTPUT
en utf-8 viewport Document structure
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.