Skip to content
engineering workbench.by StudyPort Academy
Learning path
Foundations16 minLESSON 01 / 16

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.

Opening editor…
LIVE PREVIEW
Console 0

Your console output appears here.

Saved on this deviceJavaScript · ES2022

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.

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.

Labels this document can use
KindTagsWhat they are for
Headingsh1 through h6Section titles in order of importance. h1 is the most important on the page, not merely the biggest
Textp, br, hrA paragraph, one forced line break, or a horizontal divider
Emphasisstrong, em, b, istrong and em mean important or emphasized. b and i are only a bold or italic look
Links and imagesa, imga href is a link. img src points at the file, and alt is the text if that file cannot be shown
Containersdiv, spanGeneric boxes with no meaning of their own. div groups a block of the page. span groups words inside a line
Listsul, ol, li, dlul 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.

04

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.

Opening editor…
LIVE PREVIEW
Console 0

Your console output appears here.

Saved on this deviceJavaScript · ES2022

EXPECTED CONSOLE OUTPUT

en
utf-8
viewport
Document structure

Hints 0/2

    Use all hints or make 3 failed runs (0/3).

    05

    Free sandbox

    Edit the HTML and CSS. The JavaScript tab can read the result. This draft is saved separately.

    Opening editor…
    LIVE PREVIEW
    Console 0

    Your console output appears here.

    Saved on this deviceJavaScript · ES2022
    06

    Quiz

    A quick check for understanding. Retry as often as you like; your learning path stays open.

    01Where does the language of the page belong?
    02What does the viewport meta element change?

    Ready to call this one understood?

    Mark this lesson complete to earn 100 XP. You can always revisit it.

    Sign in to save progress
    Next lesson