Lesson 4 of 51 · Module 1, lesson 4 of 6 · 5 min
Create, save and open your first page
Write your first HTML file, open it in a browser, and see your changes appear.
What you'll learn
- How to create an HTML file in VS Code
- How to open it in a browser
- The edit → save → refresh loop that you will use every day
Why this matters
This is the moment everything connects: a file you write becomes a page in a browser. From now on, every lesson follows the same routine, so it is worth doing it carefully once.
Step 1: create the file
- In VS Code, point at MY-WEBSITE in the Explorer panel. Small buttons appear next to it. Click the first one, New File…
- Type
index.htmland pressEnter.
The name index.html is special. When someone visits a folder on a website, the web server shows index.html automatically. So it is the usual name for a home page.
The new, empty file opens in the editor.
Step 2: type the page
Type this code into the file. Typing it yourself, instead of copying it, helps you remember it. Check every angle bracket < > and every slash /.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About me</title>
</head>
<body>
<h1>Hello, I am learning HTML</h1>
<p>This is my first web page.</p>
</body>
</html>
You do not need to understand every line yet — the next lesson explains each one.
The spaces at the start of some lines are for people, not for the browser. They make the code easier to read. You can use two spaces or press Tab.
Step 3: save
Press Ctrl + S (Windows) or Command + S (macOS). If you turned on Auto Save in the previous lesson, the file saves by itself.
How to check: look at the tab with the file name at the top of the editor. A white dot ● next to the name means there are unsaved changes. After saving, the dot changes back to an ×.
Step 4: open the page in a browser
Windows: open File Explorer, go to Documents › my-website, and double-click index.html.
macOS: open Finder, go to Documents › my-website, and double-click index.html.
The page opens in your usual browser. If it opens in another program instead, right-click the file, choose Open with, and pick a browser: Chrome, Edge, Firefox or Safari.
Now look at the address bar at the top of the browser. It starts with file:///. This means the browser opened a file from your own computer, not a page from the internet. It looks like one of these (with your own user name):
file:///C:/Users/ana/Documents/my-website/index.html (Windows)
file:///Users/ana/Documents/my-website/index.html (macOS)
Only you can see this page, because it is only on your computer. Putting a website on the internet is a later step.
What you'll see
- The tab says About me. That text comes from the
<title>line. - A large, bold heading: "Hello, I am learning HTML".
- A line of normal text under it.
The text is black on white, in a plain font. That is correct. Colours and fonts come later, with CSS.
Step 5: change, save, refresh
This loop is how all web development works:
- In VS Code, change the text of the paragraph, for example to:
<p>I like cooking and walking in the park.</p> - Save.
- In the browser, refresh the page: press
F5orCtrl + Ron Windows,Command + Ron macOS, or click the round arrow next to the address bar.
Your new sentence appears. Place the two windows side by side — VS Code on one half of the screen, the browser on the other — so that you can see both at once.
Try it yourself
Add a second paragraph under the first one, about something you would like to build one day. Save and refresh.
You should see two separate blocks of text, with a gap between them.
Common mistakes
- The browser shows your code as text. The file is really called
index.html.txt, or it was saved from a word processor. Fix: turn on file extensions (see Files, folders and file extensions) and rename the file toindex.html. - Your change does not appear. The file is not saved (look for the ● on the VS Code tab), or you did not refresh the browser. Fix: save, then refresh.
- Part of the page is missing. Often a
>is missing, so the browser thinks the text after it is still part of a tag. Fix: compare your code with the example, one character at a time. - Double-clicking the file opens VS Code, not a browser. Your computer is set to open
.htmlfiles with VS Code. Fix: right-click the file › Open with › choose your browser. - Editing one copy and opening another. If you copied the file somewhere else, you may be changing one copy and looking at the other. Fix: always open the file from
Documents › my-website.
Check yourself
- What is the usual file name for a website's home page?
- You changed your code, but the browser still shows the old text. What two things do you check?
- What does
file:///at the start of the address mean?
Answers
index.html- Did you save the file? Did you refresh the browser?
- The browser opened a file from your own computer, not a page from the internet.
Next: your page works. In the next lesson you will learn what each line of it means — the HTML page skeleton.



