HTML Document Structure: Head and Body
The document skeleton
A complete page begins with <!doctype html>, which requests standards mode. The html element contains head and body. The lang="en" attribute declares English as the document language; meta charset="utf-8" declares the text encoding. Attributes are covered later in this chapter.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Reading notes</title> </head> <body> <h1>Reading notes</h1> <p>Chapter one is finished.</p> </body></html>The browser tab uses the title Reading notes, and the page displays the heading and paragraph. The doctype is a declaration, not an HTML element.
Head versus body
The head holds information about the document. The title names the document, usually shown in the browser tab. Place the visible page content in body.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Trail journal</title> </head> <body> <h1>Saturday walk</h1> <p>The trail was quiet.</p> </body></html>Trail journal names the tab; Saturday walk is the visible heading. They serve different purposes.
Common mistake: confusing title and heading
Changing title does not change the visible h1. Keep both in their correct locations. Practice by creating a document whose tab title and page heading differ.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Document Structure: Head and Body — Knowledge Check
Apply the concepts and examples from this lesson.
Where should the visible main heading go?
What does <!doctype html> request?
A page has title Trail notes and h1 Sunday walk. What normally appears in the tab?
Which element declares the encoding in the lesson's skeleton?
What does lang="en" on html describe?