To write HTML you only need two things: a text editor to type the code and a web browser to view the result. You already have a browser. In this lesson you'll choose an editor, save your first .html file and open it on your own computer.
Setting up a proper editor early is worth the ten minutes it takes. A good editor colours your code so mistakes stand out, fills in closing tags for you and keeps all the files of a website together in one folder view.
Not ready to install anything yet? That's fine. Every example on Codevra runs right here in the page, and the Playground is a full editor in your browser.
Which HTML editor should you use?
Any plain text editor works, but a code editor makes life much easier. It colours your code, closes tags for you and points out typos.
| Editor | Price | Why people like it |
|---|---|---|
| VS Code | No cost | The most widely used code editor. Good for beginners and professionals. |
| Sublime Text | Trial, then paid | Very fast and lightweight. |
| Notepad (Windows) / TextEdit (Mac) | Built in | Works, but no colours or help. TextEdit must be set to plain text. |
| Codevra Playground | Online | Nothing to install, so it's handy for quick practice. |
We recommend Visual Studio Code (VS Code). It runs on Windows, Mac and Linux, and it's what most professional web developers use day to day.
Avoid word processors such as Microsoft Word or Google Docs. They save hidden formatting and replace straight quotes with curly ones, and both of those break HTML.
Create your first HTML file in 5 steps
- Install VS Code from
code.visualstudio.com. - Create a folder on your desktop called
my-website. - In VS Code choose File → Open Folder and pick
my-website. - Create a new file and save it as
index.html. The nameindex.htmlis special: web servers show it automatically as the home page of a folder. - Type
!and press Tab. VS Code writes a complete HTML page skeleton for you.
Now right-click index.html in your file explorer and choose Open with → Chrome (or any other browser). That's your page, running from your own computer.
Why saving your file matters
The browser shows the saved version of your file. If you change the code but don't save (Ctrl + S, or Cmd + S on Mac), the browser still shows the old page. Forgetting to save is the most common "why isn't it working?" moment for beginners.
VS Code marks unsaved files with a white dot on the file's tab. If you see the dot, save before you check the browser. You can also turn on File → Auto Save so you never have to think about it.
Naming files and folders
Web addresses are built from file names, so choose names that work well in a URL:
- Use lowercase letters:
about.html, notAbout.html. Many web servers treat upper and lower case as different files. - Use hyphens instead of spaces:
contact-us.html, notcontact us.html. - Always end HTML files with
.html.
Following these rules from day one saves you from broken links when your site goes online.
HTML Editor Syntax
A file name that works everywhere
index.html
about-us.html
contact.htmlUse lowercase letters, hyphens instead of spaces, and always end with .html.
HTML Editor Summary
- You need a text editor to write HTML and a browser to view it.
- VS Code is a popular code editor that highlights code and helps you type faster.
- Save files with the
.htmlextension.index.htmlis the default home page. - The browser only shows changes after you save the file.
- Use lowercase file names with hyphens instead of spaces.
HTML Editor Examples
Each example runs in the page. Edit the code and press Run to see what changes.
The page VS Code creates for you
This is what you get when you type ! + Tab in VS Code. You'll learn what every line means in the next lesson.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>It works!</h1>
</body>
</html>Line-by-line explanation
- Line 1Tells the browser "this is a modern HTML page".
- Line 2The root element that wraps everything.
lang="en"says the page is in English. - Lines 3 to 7The head holds information about the page, like its title. It isn't shown on the page itself.
- Line 6The text shown in the browser tab. Change "Document" to something meaningful!
- Lines 8 to 10The body holds everything you can see. Here, one heading.
Linking two pages together
Real websites have several files. Here's what index.html might link to. (Links between your own files use just the file name.)
<h1>My Website</h1>
<p>Welcome! Find out <a href="about.html">about me</a>.</p>
<p>Or <a href="contact.html">get in touch</a>.</p>Line-by-line explanation
- Line 2
href="about.html"points to a file calledabout.htmlin the same folder. - Line 3Same idea for a contact page. Clicking it in this preview won't navigate, but on your computer it would.
Common HTML Editor Mistakes
Saving as a .txt file
index.html.txtindex.htmlWindows sometimes hides file extensions and adds .txt. In Notepad choose Save as type: All files. In VS Code this never happens.
Spaces and capitals in file names
My First Page.HTMLmy-first-page.htmlWeb servers treat Page.html and page.html as different files, and spaces become ugly %20 in links. Lowercase and hyphens avoid both problems.
HTML Editor in Real Projects
What professionals use
Professional web developers use the same setup: VS Code (or a similar editor), a browser with DevTools open, and a live-reload tool. The only difference is they add extras like Git for saving versions and a build tool for big projects. You're starting with the real workflow.
HTML Editor Exercises
Answer each one and check it instantly. If you get stuck, open the hint before the answer.
You edit your HTML file but the browser still shows the old version. What's the most likely reason?
Which file name is best for your home page?
index.html is shown automatically when someone visits a folder on a web server.Complete the link so it opens the gallery.html file in the same folder.
<a ="">See my photos</a>
href holds the address. For a file in the same folder, the address is just its name.HTML Editor Quiz
3 questions to check what you learned.
Which of these do you need to start writing HTML?
- A paid program
- An internet connection
- A text editor and a browser
- A web server
What does the VS Code extension Live Server do?
- Publishes your site on the internet
- Reloads the browser automatically when you save
- Checks your spelling
- Converts HTML to CSS
Why should you avoid spaces in HTML file names?
- Browsers can't open them at all
- HTML forbids spaces anywhere
- They make the file larger
- They become
%20in links and are easy to mistype
HTML Editor Challenge
Change the tab title
The page below has the boring default title "Document". Change the <title> to My First Website and change the heading to say hello to you.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<h1>Hello!</h1>
</body>
</html>- The title is "My First Website"
- The heading has changed from just "Hello!"
<title> and </title> inside the head.