What you need to create an HTML file

An HTML file is a plain text document with a .html extension at the end of its name. You do not need special software — any text editor that comes with your computer will work. On Windows, that is Notepad. On Mac, that is TextEdit. On Linux, that is gedit or nano. You save the file with a name like index.html or mypage.html, and your web browser can then open it and display it as a webpage.

The reason this works is that web browsers are built to read HTML code and turn it into the pages you see. When you create an HTML file on your own computer and open it in a browser, the browser reads your code and renders it the same way it would render a page from the internet — except the file lives on your hard drive instead of on a web server.

Key Takeaways

  • You can create an HTML file using only Notepad (Windows), TextEdit (Mac), or gedit (Linux) — no paid software required.
  • Save your file with a .html extension at the end, such as index.html, so your browser recognizes it as a webpage.
  • Always save as plain text, never as rich text or .docx, or the browser will not read your code correctly.
  • Open the saved HTML file in your browser by double-clicking it or dragging it into a browser window to see how your code looks.

Creating an HTML file on Windows using Notepad

Open Notepad by pressing the Windows key, typing Notepad, and pressing Enter. A blank window will appear. Type or paste your HTML code into this window. For a first test, you can use a straightforward example like this:

<!DOCTYPE html> <html> <head> <title>My First Page</title> </head> <body> <h1>Hello World</h1> <p>This is my first webpage.</p> </body> </html>

Once you have typed or pasted your code, go to File and click Save As. In the dialog that opens, type a filename with the .html extension — for example, mypage.html. Make sure the Save as type dropdown is set to All Files, not Text Documents. Choose a folder you will remember, like your Desktop or Documents folder, and click Save. Notepad will now save your file as an HTML file that browsers can read.

Creating an HTML file on Mac using TextEdit

Open TextEdit by pressing Command + Space, typing TextEdit, and pressing Enter. A blank document will open. Before you type any code, you must change the format from rich text to plain text. Go to the Format menu at the top and click Make Plain Text. This step is important — if you skip it, your HTML file will not work because TextEdit will add invisible formatting codes that break the HTML.

Now type or paste your HTML code into the document. When you are ready to save, go to File and click Save. In the dialog that appears, type your filename with the .html extension, such as mypage.html. Choose a folder like Desktop or Documents, and click Save. If TextEdit asks whether you want to use the .html extension, click Use .html.

Creating an HTML file on Linux using gedit

Open gedit by opening your terminal and typing gedit, then pressing Enter. A text editor window will open. Type or paste your HTML code directly into the window. Gedit saves as plain text by default, so you do not need to change any format settings.

When you are ready to save, press Ctrl + S or go to the menu and click Save. Type your filename with the .html extension — for example, mypage.html — and choose where to save it. Click Save and your file is ready to open in a browser.

Opening your HTML file in a browser to see the result

Once you have saved your HTML file, you can view it in a web browser. The simplest way is to open your file manager (File Explorer on Windows, Finder on Mac, or Files on Linux), navigate to the folder where you saved your file, and double-click the HTML file. Your default web browser will open and display your webpage.

Alternatively, you can open your browser first, then drag and drop the HTML file from your file manager into the browser window. The browser will read the file and show you how your code looks. This is how you test your HTML before putting it on a web server — you see exactly what visitors will see, but the file is only on your computer.

Common mistakes that prevent HTML files from working

The most common mistake is saving the file with the wrong extension or in the wrong format. If you save as mypage.txt instead of mypage.html, the browser will not recognize it as a webpage. If you save in rich text format instead of plain text, invisible formatting will corrupt your code. Always check that your filename ends in .html and that you chose plain text before saving.

Another mistake is typing the code in a word processor like Microsoft Word instead of a plain text editor. Word adds its own formatting behind the scenes, which breaks HTML. Always use Notepad, TextEdit, gedit, or another plain text editor. If you are unsure whether your editor is plain text, look for a Format menu or a setting that says "plain text" or "no formatting" — if you see that option, use it.

Frequently Asked Questions

Can I use Microsoft Word or Google Docs to create an HTML file?

No. Word and Google Docs add invisible formatting that corrupts HTML code. You must use a plain text editor like Notepad, TextEdit, or gedit. These editors save only the text you type, with no hidden formatting.

What if I double-click my HTML file and nothing happens?

Your computer may not know which program to use to open it. Right-click the file, select Open with, and choose your web browser (Chrome, Firefox, Safari, or Edge). After you do this once, double-clicking should work.

Can I edit my HTML file after I save it?

Yes. Open the HTML file in your text editor, make your changes, and save it again. Then refresh your browser window (press F5 or Ctrl + R) to see the updated version. You do not need to create a new file each time.

Does my HTML file need to be named index.html?

No. You can name it anything you want, as long as it ends in .html. The name index.html is only special when you upload your file to a web server — servers look for index.html as the default page to show. On your own computer, any .html filename works.

What is the difference between .html and .htm?

Both extensions work the same way. .html is more common today, but .htm is an older convention from when Windows limited extensions to three letters. Use .html unless you have a specific reason not to.