The fastest way to create an HTML file
Open a plain text editor — Notepad on Windows, TextEdit on Mac, or gedit on Linux — paste in some HTML code, and save the file with a .html extension instead of .txt. That's it. Your browser can then open it and display the page.
The reason you need a plain text editor, not Word or Google Docs, is that those programs add invisible formatting codes that break HTML. A plain text editor saves only the characters you type, nothing else.
Once saved, you can open the file in any web browser by double-clicking it, or by right-clicking and choosing "Open with" and selecting your browser. The browser reads the HTML code and turns it into a visible page.
Key Takeaways
- Use a plain text editor like Notepad, TextEdit, or gedit — never Word or Google Docs, which add hidden formatting.
- Save your file with a .html extension at the end of the filename, not .txt.
- Open the saved file in your browser by double-clicking it or right-clicking and selecting your browser from the menu.
- For ongoing work, a code editor like Visual Studio Code or Sublime Text shows you errors and highlights code structure as you type.
Creating an HTML file on Windows
Open Notepad by pressing the Windows key, typing "notepad", and pressing Enter. Type or paste your HTML code into the blank window. A basic starting point is:
<!DOCTYPE html> <html> <head> <title>My Page</title> </head> <body> <h1>Hello World</h1> </body> </html>
Go to File, then Save As. In the filename field, type a name followed by .html — for example, mypage.html. Make sure "Save as type" is set to "All Files" rather than "Text Documents (.txt)". Choose where you want to save it and click Save.
Navigate to the folder where you saved the file, find it in File Explorer, and double-click it. Your default browser will open and display the page. If you want to use a different browser, right-click the file, select "Open with", and choose the browser you prefer.
Creating an HTML file on Mac
Open TextEdit by pressing Command+Space, typing "textedit", and pressing Enter. Before you type anything, go to Format menu and click "Make Plain Text". This is the critical step — if you skip it, TextEdit will save hidden formatting codes along with your HTML.
Type or paste your HTML code. Then go to File, click Save, and give your file a name with the .html extension — for example, mypage.html. TextEdit will ask whether you want to use the .html extension; click "Use .html".
Open Finder, navigate to where you saved the file, and double-click it. Safari or your default browser will open and show the page. To use a different browser, right-click the file and select "Open With" from the menu.
Creating an HTML file on Linux
Open a text editor. The most common is gedit, which you can launch by opening the Activities menu, typing "gedit", and pressing Enter. Some Linux systems use nano or vi instead, which run in the terminal — if you're not familiar with those, gedit is simpler to start with.
Type or paste your HTML code into the editor. Go to the menu (usually three horizontal lines), click Save, give your file a name with the .html extension, and choose a location. Click Save.
Open your file manager, find the file you just saved, and double-click it. Your default browser will open and display the page. If nothing happens, right-click the file, select "Open With", and choose your browser from the list.
Why a code editor is worth learning
Plain text editors work fine for learning, but once you write more than a few lines of HTML, a code editor like Visual Studio Code, Sublime Text, or Atom becomes much faster. These programs highlight different parts of your code in different colors, show you when you've forgotten to close a tag, and let you save and preview changes without leaving the editor.
Visual Studio Code is free and works on Windows, Mac, and Linux. After you install it, you can create a new file, paste HTML into it, save it with a .html extension, and use the built-in preview feature to see changes instantly. Most people who write HTML regularly use a code editor rather than Notepad.
For now, though, a plain text editor and your browser are all you need to learn how HTML works and see your code displayed as a web page.
Saving changes and viewing them in your browser
After you save an HTML file and open it in your browser, making changes is straightforward. Open the file again in your text editor, make your changes, and save the file. Then go back to your browser and press F5 (or Ctrl+R on Mac) to refresh the page. The browser will reload the file and show your updates.
If you're switching between your editor and browser often, you can arrange your windows side by side so you can see both at once. Make a change in the editor, save, refresh the browser, and see the result immediately. This is how most people learn HTML — by making small changes and watching what happens.
Common mistakes when creating an HTML file
The most common mistake is saving the file with a .txt extension instead of .html. If you do this, your browser will try to open it as plain text rather than as a web page. The fix is simple: rename the file in your file manager or File Explorer, change the extension from .txt to .html, and open it again.
The second mistake is using a word processor like Word or Google Docs. These programs save invisible formatting that breaks HTML. Always use a plain text editor. On Mac, the most common error is forgetting to click "Make Plain Text" in TextEdit before typing — if you forget, delete the file and start over with a new TextEdit window.
The third mistake is typing the filename as mypage.html.txt instead of mypage.html. This happens when you type the extension in the filename field but the editor also adds .txt automatically. Check the actual filename in your file manager to make sure it ends in .html only.
Frequently Asked Questions
What's the difference between .html and .htm?
Both extensions work identically. .html is more common on modern systems, but .htm exists because older Windows systems limited filenames to three-letter extensions. Use .html unless you have a specific reason not to.
Can I create an HTML file on my phone?
Yes, but it's awkward. You need a plain text editor app — not Notes or Messages. Apps like Jota+ (Android) or Textastic (iPhone) work, but a computer is much faster for writing HTML. If you do use your phone, save the file, email it to yourself, and open it on your computer to test it in a browser.
Do I need internet to create and view an HTML file?
No. HTML files work completely offline. You can create them, save them, and open them in your browser without any internet connection. Internet only matters if your HTML links to images or other files on the web.
What if my browser shows the HTML code instead of the page?
This usually means the file was saved as .txt instead of .html. Rename the file in your file manager to end in .html, then open it again. If that doesn't work, right-click the file, select "Open With", and choose your browser explicitly instead of letting Windows or Mac choose.
Can I edit an HTML file after I've created it?
Yes. Open the file in your text editor, make changes, save it, and refresh your browser. You can edit an HTML file as many times as you want. The file stays the same until you change it — opening it in your browser doesn't modify anything.