Plate 1.1 · Phase 1 — Framing · 20 minutes · First module of Phase 1
Your first web page, from a blank file
Everything up to now was preparation. In this module you create a file that did not exist, type about twelve lines into it, and open it in a browser as a real web page. This is the moment it stops being theoretical.
Warm-up · from Module 0.4You need a new code file. Where do you make it, so no hidden .txt sneaks onto the end?
In VS Code's sidebar, with your project folder open — New File. Notepad and TextEdit can add .txt without showing you; VS Code saves exactly the name you type.
What you're actually about to do
Here is the whole job, and it does not get more complicated than this — only more detailed. You will write text with labels wrapped around it. The browser reads the labels and decides what everything is. That's HTML. There is no third step.
By the end of the module you'll have a page with your name on it — the index.html you created in VS Code in Module 0.4, inside your portfolio folder — open in a Live Preview that updates as you type.
The anatomy of a tag
A tag is a label you wrap around content to say what it is. It comes in a pair — one to open, one to close — and the closing one is the same word with a slash. Click each part below.
Click any colored piece of the tag above.
Take one paragraph and split it into its five parts.
<p class="intro">Welcome to my page.</p>
| Piece | Text | What it does |
|---|---|---|
| Opening tag | <p | Names the element and starts it. |
| Attribute | class="intro" | A name, an equals sign, and a quoted value. It adds detail; it never changes what the element is. |
| End of the opening tag | > | Finishes the label. Leave it out and the browser reads your sentence as part of the tag. |
| Content | Welcome to my page. | The only part a visitor sees. |
| Closing tag | </p> | The same name with a slash. The element ends here. |
Notice that only the content is visible on the page. Everything else is an instruction to the browser.
The tags are the labels; the element is the labeled thing.
Opening tag, content, closing tag — the whole thing together is called an element. You will hear "tag" and "element" used loosely, including by professionals.
A few tags don't wrap anything
Most elements surround content. A handful just are — an image, a horizontal rule, a line break. They have no closing tag because there's nothing inside them to close.
Two kinds of markers
- A fence around a garden
- It encloses something. It has a start and an end, and everything between them is inside it.
- A road sign
- It stands on its own. Nothing is inside it; it simply is, at that spot.
Two kinds of elements
- Normal elements
<p>…</p>,<h1>…</h1>,<li>…</li>. Opening tag, content, closing tag.- Void elements
<img>,<br>,<hr>,<meta>,<link>. One tag, no closing tag, ever. Writing</img>is simply wrong. (Prettier may rewrite them as<img … />with a slash at the end — that trailing slash is optional and harmless.)
The skeleton every page has
Every HTML document on the internet starts the same way. You will type this so many times that VS Code has a shortcut for it — but type it by hand today, once, so the parts mean something.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>My first page</title>
</head>
<body>
<h1>Hello, world</h1>
</body>
</html>
| Line | What it does | In plain terms |
|---|---|---|
| <!DOCTYPE html> | Tells the browser to use modern standards rather than a 1998 compatibility mode. | The building permit. Nobody reads it, but leave it out and things get strange. |
| <html lang="en"> | Wraps the entire document and states its language. | The property line. lang matters: screen readers use it to choose a voice, and browsers to offer translation. |
| <head> | Information about the page. None of it appears on the page itself. | The label on the outside of the box. The browser and Google read it; visitors don't. |
| <meta charset="UTF-8"> | Says which alphabet the file uses. | Leave it out and accented letters, curly quotes and em dashes turn into garbage. |
| <meta name="viewport"…> | Tells phones to use their real width instead of pretending to be a desktop. | Without it, your site appears zoomed-out and tiny on every phone. Non-negotiable. |
| <title> | The name of the page. | What shows in the browser tab, in bookmarks, and as the blue headline in Google results. |
| <body> | Everything a visitor actually sees. | The room people walk into. From here on, almost all your work happens between these two tags. |
In VS Code, in an empty .html file, type a single exclamation mark ! and press Tab. The entire skeleton appears. That's a system called Emmet, built in, no extension needed. Use it from tomorrow — but type the skeleton by hand today, because a shortcut for something you don't understand is just a magic spell.
Nesting: boxes inside boxes
Elements go inside other elements, and the rule is the same as parentheses in arithmetic: whatever you opened last, you close first. Overlap them and you get a page that renders in ways nobody intended.
Correct
<p>This is <strong>important</strong> news.</p>
strong opened last, so it closes first. The bold text sits cleanly inside the paragraph.
Broken
<p>This is <strong>important</p> news.</strong>
The paragraph closes while strong is still open. Every browser repairs this the same way, by fixed rules — but the repair is rarely what you meant: here the paragraph ends early and news. ends up bold outside it. On a real page, one overlap like this can make the layout go strange from that point down.
Indentation is how professionals keep this straight — every level of nesting moves two spaces to the right, so the structure is visible at a glance. The browser doesn't care; humans do, and you will be a human reading your own code next Tuesday. This is also exactly what Prettier does for you automatically, from Module 0.4.
Build it here first
Below is the skeleton, live. Type on the left; the page rebuilds on the right, and the fake browser tab shows your <title>. Four small challenges tick themselves off as you get them right. Nothing can break — it's your copy.
Start from this small page and make four changes. Write your answers on the lines beside each step.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My first page</title> </head> <body> <h1>Hello, world</h1> </body> </html>
- Change the
<h1>text to your own name. - Change the
<title>. The browser tab shows it, not the page. - Add a
<p>paragraph under the heading. - Add an
<h2>and a<ul>holding three<li>items.
When you finish, the body should hold a heading, a paragraph, a second heading, and a list of three items. Type it into a file and open it in a browser to check.
In the editor above, press Enter five times between two words in the heading, and add ten spaces. Look at the preview: nothing moved. HTML collapses every run of whitespace into a single space. Line breaks and indentation are for you, not for the browser — which is why you cannot lay out a page by pressing Enter, and why Phase 2 exists at all.
Comments: notes to humans
Anything between <!-- and --> is ignored by the browser. Use it to label sections of a long page, or to switch a chunk of HTML off temporarily while you test something — the same move as Ctrl/Cmd + / from Module 0.4.
<!-- Contact section starts here --> <h2>Get in touch</h2>
One warning: comments are invisible on the page but perfectly visible to anyone who views the source. Never put a password, an internal note about a client, or anything you wouldn't say out loud into a comment.
Three things beginners get wrong
1. Forgetting the closing tag. On most elements, the element then swallows everything after it, and the page looks bizarre in a way that seems unrelated to what you typed. When something goes strange from a certain point downward, look for an unclosed tag just above that point.
2. Expecting Enter and the spacebar to lay things out. They don't, as you just saw. Spacing, columns and gaps are CSS, and that's Phase 2.
3. Saving the file wrong. If your browser shows you the code as text instead of a page, the file isn't really .html — it's index.html.txt. Module 0.3 told you to turn file extensions on; this is the day it pays off.
Words you now own
- tag
- The label itself:
<p>opens,</p>closes. - element
- The whole thing — opening tag, content, closing tag.
- attribute
- Extra detail on an opening tag, as
name="value". - void element
- An element with no content and no closing tag:
<img>,<br>,<hr>. - nesting
- Elements inside elements. Close them in the reverse order you opened them.
- doctype
- The first line, telling the browser to use modern standards.
- head
- Information about the page. Invisible to visitors.
- body
- Everything visitors see.
- boilerplate
- The standard skeleton you start every page with.
- Emmet
- VS Code's built-in shorthand.
!then Tab writes the skeleton.
Now do it for real, on your own machine.
What you should see — one way to do it
Your index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Maria Lopez</title>
</head>
<body>
<h1>Maria Lopez</h1>
<p>
I'm learning to build websites so I can make one for my
family's bakery.
</p>
</body>
</html>
In Live Preview
A large bold name at the top, a plain paragraph beneath it, black text on white, in the browser's default font. That plainness is correct — there's no CSS yet. The preview's tab (or the browser tab, if you open it there) shows your name, from <title>.
When you deleted </h1>
The paragraph below turned big and bold too: the unclosed heading swallowed it. That's what "everything after it goes strange" looks like.
If you see code instead of a page
You opened the file in a text viewer, or it's secretly index.html.txt. Use Live Preview from VS Code's right-click menu.
Six questions. Four correct to move on.
"A tag is a label. An element is a label plus what's inside it. The head is for the browser, the body is for people. Whitespace collapses." You have written a web page. Everything from here is more elements, better structure, and eventually a lot of CSS — but the shape of the work does not change.