By now you have the tools to write the “content” of your text—tags and attributes. But before that, one important thing. Actually, an HTML file has a fixed outer frame to write the content into. It’s the template you caught a glimpse of back in “Getting Ready.” Let’s really make it your own here.
This is the basic template
A blank HTML file always starts from this shape.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Shima's Homepage</title>
</head>
<body>
<h1>Shima</h1>
<p>You'll write the content here.</p>
</body>
</html>Look at it part by part, and it’s not scary.
| Part | Role |
|---|---|
<!DOCTYPE html> | The first greeting that says “this is an HTML document” (the magic first line) |
<html> | The outermost box that wraps the whole page |
<head> | The room where you write behind-the-scenes information (the title, etc.; doesn’t show on screen) |
<body> | The room where you write the content visible on screen ←★ this is the star |
lang=“en” is the declaration “this page is in English”
The lang="en" in <html lang="en"> is the attribute you learned last time. It’s a declaration that “this page is written in English (en = english),” and it’s a note passed along to the browser, screen readers, and search engines. Write the code for whatever language you’re using—ja for a Japanese page, for example.
Use indentation to make “nesting” easy to see
Look closely at the basic template, and the <head> and <h1> lines are written shifted a little to the right. This is called indentation, a way of writing that makes it visible at a glance “which tag this tag sits inside.”
<head>and<body>are inside<html>→ indent one level<title>and<h1>are inside those → indent one more level
The display is the same even without indentation. But the nesting shape of boxes inside boxes is visible at a glance, so you’ll quickly notice a forgotten closing tag too. In VSCode it lines things up automatically every time you start a new line, so as long as you write without breaking that shape, you’ll be fine.
The division of roles between the two rooms
What matters is the difference in roles between <head> and <body>.
<head>— The page’s settings and behind-the-scenes information. Doesn’t show on screen.<body>— The content that actually appears on screen. Headings, paragraphs, images—all of it here.
The <h1> and <p> you’ve learned so far, and the images and links coming up, all go inside <body>.
Summary of this lesson
- An HTML file has
<head>and<body>inside<html> <head>is behind the scenes (doesn’t show on screen),<body>is the main stage (shows on screen)- Content like headings, paragraphs, and images all goes inside
<body> - Declare what language the page is in with
lang="en", and make nesting easy to see with indentation