What an HTML file actually is and how to make one
An HTML file is a plain text document that your web browser reads and turns into a webpage. You create one by typing HTML code into a text editor, saving it with a .html extension, and then opening it in a browser. That's the entire process — you don't need special software or an internet connection to create the file itself.
The confusion usually comes from thinking HTML requires something complicated. It doesn't. You already have everything you need: a text editor (Notepad on Windows, TextEdit on Mac, or any similar program) and a web browser. The file extension .html is what tells your computer "this is a webpage".
The steps below walk you through creating a basic HTML file, saving it correctly, and opening it in your browser so you can see what you've made.
Key Takeaways
- HTML files are plain text documents saved with a .html extension, not a special file type that requires paid software.
- You can create an HTML file using Notepad (Windows), TextEdit (Mac), or any plain text editor — not Microsoft Word or Google Docs.
- The file must be saved as .html or .htm, not as .txt, or your browser will treat it as text instead of a webpage.
- Once saved, you open the HTML file by double-clicking it or dragging it into your browser, and the browser displays it as a webpage.
Creating your HTML file on Windows using Notepad
Open Notepad by pressing the Windows key, typing "Notepad", and pressing Enter. A blank text window opens. Type or paste your HTML code into this window. A basic starting point is:
<!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've typed or pasted the code, go to File and click Save As. A dialog box opens. In the filename field, type a name followed by .html — for example, mypage.html. Make sure the "Save as type" dropdown at the bottom is set to All Files (*.*), not "Text Documents (.txt)". If you leave it on Text Documents, Windows will save it as mypage.html.txt, and your browser won't recognize it as a webpage. Choose where you want to save it (your Desktop or Documents folder is fine), then click Save.
The file now exists on your computer as an HTML file. You can close Notepad.
Creating your HTML file on Mac using TextEdit
Open TextEdit by pressing Command + Space, typing "TextEdit", and pressing Enter. A blank document opens. Before you type any code, you must change TextEdit to plain text mode. Go to Format in the menu bar and click Make Plain Text. This step is critical — if you skip it, TextEdit will add invisible formatting that breaks your HTML.
Now type or paste your HTML code into the document. Use the same basic code shown above. Once you've entered the code, go to File and click Save. A dialog box opens. In the filename field, type a name followed by .html — for example, mypage.html. Choose where you want to save it (your Desktop or Documents folder works), then click Save. If TextEdit asks whether to use the .txt extension instead, click Use .html.
Close TextEdit. Your HTML file is now saved and ready to open.
Opening your HTML file in a web browser
Find the HTML file you just saved. On Windows, it will have a small browser icon next to its name. On Mac, it will show a generic document icon. Double-click the file. Your default web browser opens and displays your webpage. You should see "Hello World" as a large heading and "This is my first webpage." as regular text below it.
If the file opens as text instead of a webpage (you see the raw HTML code), the file was saved with a .txt extension instead of .html. Go back and rename it: right-click the file, select Rename, and change the extension from .txt to .html. Then double-click it again.
You can also open the file by launching your browser first, then going to File > Open and navigating to your HTML file. This method works the same way and is useful if you want to choose which browser displays the file.
Editing your HTML file after you've created it
To change the content of your webpage, you need to edit the HTML file itself, not the webpage displayed in your browser. Right-click the HTML file and select Open with, then choose your text editor (Notepad on Windows, TextEdit on Mac). Make your changes to the code, save the file, and then refresh your browser window (press F5 or Ctrl+R on Windows, or Command+R on Mac). The browser will reload the file and show your updates.
A common mistake is trying to edit the webpage directly in the browser window. You can't — the browser only displays what the HTML file tells it to. All changes must be made in the text editor, saved, and then viewed in the browser.
Understanding file extensions and why .html matters
A file extension is the short code after the period in a filename — .html, .txt, .jpg, and so on. It tells your computer what kind of file it is and which program should open it by default. When you save a file as mypage.html, Windows and Mac both know it's a webpage and will open it in your browser when you double-click it.
If you accidentally save it as mypage.txt, your computer treats it as a text file and opens it in Notepad or TextEdit instead of your browser. The HTML code inside is the same, but the extension changes how your computer handles it. This is why the save step is so important — you must explicitly type .html at the end of the filename and make sure your text editor doesn't add .txt automatically.
Both .html and .htm work identically. The three-letter version .htm is older and less common now, but browsers accept both. Stick with .html unless you have a specific reason not to.
What to do if your HTML file won't open in a browser
If double-clicking your file opens it in a text editor instead of a browser, the file extension is wrong. Right-click the file, select Rename, and change the extension to .html. If you can't see the extension, you may need to turn on file extensions in your system settings. On Windows, open File Explorer, go to View, and check the box for File name extensions. On Mac, open Finder, go to Finder > Preferences, click Advanced, and check Show all filename extensions.
If the file opens in a browser but displays the raw HTML code instead of a formatted webpage, the file was saved as plain text with invisible formatting. Delete it and create a new one, making sure to use a plain text editor (Notepad or TextEdit in plain text mode) and save with the .html extension.
If you created the file on Mac using TextEdit and forgot to switch to plain text mode before typing, the file contains hidden formatting that breaks the HTML. The easiest fix is to create a new file: open Notepad or TextEdit in plain text mode, paste your HTML code, and save it as .html.
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 breaks HTML code. You must use a plain text editor like Notepad, TextEdit (in plain text mode), or a code editor. These programs save only the text you type, with no hidden formatting.
What's the difference between .html and .htm?
They work identically. The .htm extension is older and comes from when operating systems limited extensions to three letters. Modern systems and browsers accept both. Use .html unless you have a specific reason not to.
Do I need internet to create and view an HTML file?
No. You can create HTML files and open them in your browser entirely offline. The internet is only needed if your HTML code links to images or resources hosted online, or if you want to upload the file to a web server so others can view it.
Can I create an HTML file on my phone or tablet?
Yes, but it's more difficult. You need a plain text editor app — most phones come with note-taking apps that add formatting. Search your app store for "plain text editor" or "code editor". Create your file, save it with the .html extension, and open it in your phone's browser. Desktop or laptop is much easier for this task.
What happens if I save my HTML file with the wrong name?
If the extension is wrong (like .txt instead of .html), your browser won't recognize it as a webpage. Right-click the file, select Rename, and change the extension to .html. The filename itself (the part before the period) can be anything — mypage.html, index.html, test123.html all work the same way.