Setting up your first HTML file
What we will go through
- Choosing a free code editor
- Creating a project folder
- Saving a file as index.html
- Opening and refreshing it in the browser
Short answer
To make an HTML file, open a code editor, type some HTML, and save the file with a .html extension, such as index.html. Then double click the file to open it in your browser. Every time you save a change, refresh the browser to see it. That loop of edit, save, refresh is how all web development starts.
Pick a code editor
A code editor is a text editor made for code. It colors your tags and catches typos. Good free choices:
- Visual Studio Code (VS Code): free, works on Windows, Mac, and Linux. The most popular choice.
- Notepad++: light and fast on older Windows laptops.
- Acode or Spck Editor: Android apps if you only have a phone.
Avoid Microsoft Word or Google Docs. They add hidden formatting that breaks HTML.
Organize your project folder
Create one folder for each website. Keep names lowercase with no spaces.
my-first-site/
index.html
about.html
images/
logo.png
css/
style.css
index.html is special. Web servers show it by default when someone visits a folder, so it acts as your homepage.
Your first file
Paste this into a new file in your editor:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first page</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>This is my first webpage.</p>
</body>
</html>
Save it as index.html inside your folder. Make sure the file is not saved as index.html.txt. On Windows, turn on File name extensions in File Explorer’s View menu to check.
The edit, save, refresh loop
- Change something in the editor.
- Save with
Ctrl + S(orCmd + Son Mac). - Switch to the browser and refresh with
F5orCtrl + R.
In VS Code, the free Live Server extension refreshes the browser for you every time you save.
Set up VS Code in five steps
Step 1 of 5
Download VS Code
Go to code.visualstudio.com and install the version for your computer. It is free.
Create a folder
Make a folder called my-first-site on your Desktop.
Open the folder
In VS Code, choose File, then Open Folder, and pick my-first-site.
Make index.html
Click the New File icon, name it index.html, and type ! then press Tab. VS Code writes a starter page for you.
Open in browser
Save, then double click index.html in your folder. It opens in your default browser.
Try it: make it yours
This is a complete starter file. Change the title and heading to your name, then add a second paragraph about where you are from.
Live preview
Quick quiz
Common mistakes
- Saving as .txt. Hidden file extensions on Windows can turn index.html into index.html.txt.
- Spaces in file names. They turn into %20 in URLs. Use hyphens instead.
- Forgetting to save. If nothing changes on refresh, check that you saved the file.
- Editing the wrong copy. Keep one project folder so you do not edit a duplicate.
Your action
Tick each item when you can do it. Your progress saves on this device.
Key terms
- Code editor
- A text editor built for writing code, like VS Code.
- File extension
- The letters after the dot that tell the computer the file type, like .html.
- index.html
- The default homepage file a web server loads for a folder.
- Live Server
- A VS Code extension that auto refreshes the browser on save.
- Project folder
- One folder that holds all files for one website.
Questions beginners ask
Can I write HTML on my phone?
Yes. Android apps like Acode work, and so does the live editor on this page. A laptop is easier for bigger projects.
Do I need internet to write HTML?
No. HTML files open from your computer without internet.
How do I put my page online?
You upload the files to a web host. Free options include GitHub Pages and Netlify. That comes after this course.
What is Emmet?
Emmet is a shortcut tool built into VS Code. Typing ! and Tab creates a full HTML starter.
Related lessons
Need a website built or fixed while you practice? The team at Remar Digital can help.