Set up your tools and create your first HTML file
Install a free code editor, create index.html and see your first page in the browser.
In this lesson you will
- Install a free code editor and Live Server
- Create and name files the professional way
- Open your page in the browser and refresh instantly
- Fix the five most common set-up problems
About 10 minutes
You only need two things
To write websites you need a place to type and a place to look. The place to look is the browser you already have. The place to type is a code editor, which is a text editor with helpful extras such as colour, auto-closing tags and shortcuts. Windows Notepad and macOS TextEdit can technically work, but they invite mistakes, so use a proper editor from the start.
Choosing an editor
| Editor | Cost | Why people pick it |
|---|---|---|
| Visual Studio Code | Free | The industry standard. Thousands of add-ons, built-in terminal, works on Windows, Mac and Linux. |
| Sublime Text | Free to try | Very fast and light, good on older computers. |
| Notepad++ | Free | Windows only, simple and quick. |
| Browser editors | Free | CodePen and similar sites need no install. Good for quick experiments. |
This course assumes Visual Studio Code, usually shortened to VS Code, but every step works in any editor.
Set up VS Code in five minutes
- Visit code.visualstudio.com and download the installer for your system. Run it and accept the defaults.
- Open VS Code. On the left, open the Extensions icon, search for Live Server, and click Install. It refreshes your page automatically every time you save.
- Create a folder on your computer called
my-website. Keep it somewhere easy, such as Documents. - In VS Code choose File, Open Folder and select
my-website. - Click the New File icon next to the folder name and type
index.html. The name matters, as you will see below.
Why the file is called index.html
When a visitor opens yoursite.com without naming a file, the server looks for a file called index.html and shows that. Every website has one. Starting today with that name means your project will work on a real host later without changes.
File and folder naming rules
Names on the web are picky. A bad name that works on your laptop can break the moment you upload the site. Follow these rules and you will avoid the whole class of problem.
- Use lower case only:
about-us.html, notAbout Us.html. - Use hyphens instead of spaces:
contact-form.html. - Avoid symbols, accents and emoji in file names.
- Always include the extension,
.htmlfor pages,.jpgor.pngfor images.
Windows can hide extensions, so a file you think is index.html may really be index.html.txt. In File Explorer open View, then tick File name extensions so you can see the truth.
Type your first page
Put this into index.html. Do not copy and paste it. Typing it builds muscle memory, and VS Code will auto-close tags for you, which is a nice feature to see in action.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My first page</title>
</head>
<body>
<h1>Hello from my computer</h1>
<p>I built this page myself.</p>
</body>
</html>
Do not worry about every line yet. Lesson 3 explains the skeleton in detail. For now the key part is inside <body>: that is what shows on screen. The <title> text appears on the browser tab.
Open it in the browser
You have two ways to see your page.
- Double-click the file in your folder. It opens in your default browser. The address bar will start with
file://, which means it is local to your computer. - Right-click inside VS Code and choose Open with Live Server. The page opens at an address such as
127.0.0.1:5500and refreshes every time you press save.
Live Server is the one to use day to day. Change a word, press Ctrl + S (Cmd + S on Mac), and the browser updates before you can switch windows.
Ctrl+S saves. Ctrl+Z undoes. In VS Code, typing ! and pressing Tab creates a full page skeleton. Alt+Shift+F tidies the indentation. These alone will save you hours.
Practise the edit cycle here
The same cycle of change, save, look works in this live editor, so try it before you set up your own.
Change the title text inside the heading and add a second heading using <h2> with the words “Things I will learn”.
<h1>My learning page</h1>
<p>Day 1 of learning HTML.</p>
Headings come in six sizes, h1 to h6. A level 2 heading is <h2>...</h2>.
<h1>My learning page</h1>
<p>Day 1 of learning HTML.</p>
<h2>Things I will learn</h2>
<p>HTML, CSS and JavaScript.</p>
If something goes wrong
| Symptom | Likely cause | Fix |
|---|---|---|
| The browser shows the raw code | File saved as .txt |
Rename the file to end in .html |
| Changes do not appear | You did not save, or you are viewing an old tab | Press Ctrl+S, then refresh with Ctrl+R |
| Strange characters such as ’ | Missing UTF-8 declaration | Add <meta charset="UTF-8"> in the head |
| Live Server option is missing | Extension not installed or folder not opened | Reinstall it and use File, Open Folder |
| Page is blank | Content is outside <body> or a tag is unclosed |
Check each opening tag has its closing partner |
Good habits from the first day
- Keep every project in its own folder.
- Indent child elements by two spaces so the structure is visible.
- Save often, and refresh often. Small steps make errors easy to find.
- Read error behaviour, not just errors. HTML rarely shows error messages, so look carefully at what the page does.
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
What is a code editor?
- A website that hosts pages
- A text editor with features that help you write code
- A browser add-on
- A type of server
It is a text editor made for code, with colouring, auto-closing tags and shortcuts.
Why name the home page index.html?
- It runs faster
- Servers look for that file by default when no file is named
- Browsers refuse other names
- It makes the page secure
When someone visits a folder or domain with no file name, the server shows index.html.
Which file name is best practice?
My Page.HTMLmy page.htmlmy-page.htmlmy_page!.html
Lower case with hyphens avoids problems on servers that treat names as case sensitive.
Your page opens as raw code in the browser. The most likely cause is:
- The browser is too old
- The file was saved with a .txt extension
- You used too many tags
- Your computer is offline
A file ending in .txt is shown as plain text. Rename it to .html.
What does the Live Server extension do?
- Uploads your site to the internet
- Checks your spelling
- Refreshes the browser each time you save
- Compresses images
It serves your folder locally and reloads the page automatically after every save.
Summary
- A code editor makes writing HTML faster and safer.
- Home pages are named index.html, in lower case with hyphens for other files.
- Live Server refreshes your page every time you save.
- Check hidden file extensions when a file will not behave.
Questions
Can I learn HTML on my phone?
You can practise in the lesson editors on a phone, but for real projects a computer is far easier. A cheap laptop is plenty.
Is VS Code safe and really free?
Yes. It is a free, open source editor from Microsoft that millions of developers use.
Do I need an internet connection to write HTML?
No. Your files and browser work offline. You only need internet to download tools and to publish your site.
Which browser should I use for development?
Chrome, Edge or Firefox all have excellent developer tools. Test in at least two browsers before you share anything.
