Challenge - Document skeleton
Test the basics by writing a full HTML document skeleton from scratch.
Recall the document skeleton
An HTML document begins with a fixed skeleton the browser recognizes. <!DOCTYPE html> declares the document type; <html lang="en"> is the root element; <head> carries metadata and <body> carries the visible content.
The metadata includes charset for the character set, viewport for the mobile scale, and <title> for the tab title. Without these the page still opens but does not behave correctly; building the full skeleton should become a habit.
Exercise Write the full document skeleton
Write an HTML document from scratch. Start with <!DOCTYPE html>; use <html lang="en"> as the root. In head add a meta with charset="utf-8", a second meta named viewport, and <title>My Page</title>. In body put an <h1> and a <p>.
Show example solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Page</title>
</head>
<body>
<h1>Hello</h1>
<p>My first page.</p>
</body>
</html>
Test yourself
-
Complete the viewport meta tag
<meta charset="utf-8"> <meta name="____" content="width=device-width, initial-scale=1.0">Show answer
<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> -
Match each tag to its role
- <!DOCTYPE html>
- Document type declaration
- <html>
- Document root
- <head>
- Metadata
- <body>
- Visible content
- <title>
- Tab title
-
Where does the <title> element go in an HTML document?
<!DOCTYPE html> <html lang="en"> <head> <title>My page</title> </head> <body></body> </html>- Inside body
- Inside head
- Outside the html element
- Before the doctype declaration
Show answer
Inside head — Correct. <title> lives inside head; it sets the text shown in the tab.