How to Create an HTML File
Creating an HTML file sounds like it should need special software, an account, or at least some setup. It doesn't. An HTML file is a plain text file with a different ending, and you can make one with tools that are already on your computer right now. If you can save a document, you can build a web page.
Here's the thing worth knowing before you start: the word "HTML" scares people off, but the file itself is nothing more than text. What makes it a web page is the .html at the end of its name and a bit of structure inside. Get those two things right and a browser will happily turn it into a page. Let's walk through it.
Step 1: Open a plain text editor
You need something that saves plain text, not a word processor. Notepad on Windows or TextEdit on a Mac both work in a pinch. The catch with those is they'll sometimes fight you over formatting, so if you plan to do this more than once, a real code editor like Phoenix Code or VS Code makes life easier — it colours your code, closes your tags for you, and won't sneak in hidden formatting. But to make your very first file, whatever you have is fine.
Step 2: Write the smallest page that works
Every HTML file follows the same skeleton. Type this in exactly as you see it:
<!doctype html>
<html>
<head>
<title>My First Page</title>
</head>
<body>
<h1>Hello, world</h1>
<p>This is my first web page.</p>
</body>
</html>
That's a complete, working web page. The <head> holds information about the page, like its title. The <body> holds what people actually see. The tags in angle brackets are just labels telling the browser "this is a heading," "this is a paragraph." You'll learn the rest as you go, but this is enough to see something real.
Step 3: Save it with the right extension
This is the step that trips almost everyone up. When you save, don't call it page.txt — call it index.html. In Notepad, set Save as type to All Files first, or it will quietly bolt .txt onto the end and you'll wonder why your page shows up as a wall of code. On a Mac in TextEdit, choose Format → Make Plain Text before you save, then use the .html ending.
Why index.html? It's the traditional name for a site's main page, and it's a good habit. But any name works as long as it ends in .html and has no spaces.
Step 4: Open it and see your page
Find the file, double-click it, and it should open in your browser showing "Hello, world" as a big heading. If it opens as code instead of a page, the extension probably saved wrong — rename it so it ends cleanly in .html. (We wrote a whole piece on how to open an HTML file if that part gives you trouble.)
The shortcut: skip the setup entirely
If wrangling default programs and file extensions sounds like more friction than you signed up for, you can create and preview an HTML file without saving anything to your machine at all. Open a free online HTML editor in your browser, type your markup on one side, and watch the page render live on the other. Nothing to install, nothing to configure — you write a line, you see it appear. When you're happy with it, download the finished .html file.
For a lot of beginners that's the friendliest way to start. You get the write-and-see loop immediately, without the "why won't this save correctly" detour, and you can move to a desktop editor later once the ideas stick.
A few things that commonly go wrong
- The page shows raw code, not a heading. The file saved as
.txtor.html.txt. Rename it so the name ends in.htmland nothing after it. - Nothing appears at all. Check you closed your tags — every
<body>needs a</body>. A missing slash is the usual culprit. - Your styling doesn't show up. If you linked a CSS file, it has to sit in the same folder as your HTML file, or the browser can't find it.
That's genuinely all there is to the first file. Text in, .html on the end, browser paints it into a page. Once you've made one, making the next hundred is muscle memory — and an online HTML editor is there for the times you just want to try something without the ceremony of saving files.