An HTML file is a plain text document with a .html extension that a web browser can read and display as a webpage

You do not need special software to create one. Any text editor — Notepad on Windows, TextEdit on Mac, or gedit on Linux — can write the code. The key is saving the file with a .html or .htm extension instead of .txt, and understanding that the browser reads the tags you write and turns them into formatted text, images, and links on screen.

The process takes three steps: open a text editor, write or paste HTML code, and save the file with the correct extension in a location you can find later. Once saved, you can open that file in any web browser to see how it looks.

Key Takeaways

  • Save your file with a .html extension, not .txt, so the browser recognizes it as a webpage rather than plain text.
  • Use a plain text editor like Notepad or TextEdit — not Word or Google Docs, which add invisible formatting that breaks HTML.
  • Create a folder on your desktop or in Documents to keep your HTML files organized and easy to locate.
  • Test your file by dragging it into a web browser or right-clicking and choosing "Open with" to see how the code displays.

Creating a basic HTML file on Windows

Open Notepad by pressing the Windows key, typing "Notepad", and clicking the result. You now have a blank text editor. Type or paste your HTML code — even a simple example like <h1>Hello World</h1> will work to start.

Go to File, then click Save As. In the dialog that opens, navigate to a folder where you want to keep the file — your Desktop or a Documents subfolder both work well. In the filename field at the bottom, type a name followed by .html, such as mypage.html or index.html. Make sure the "Save as type" dropdown shows "All Files" rather than "Text Documents (.txt)". Click Save.

Notepad will now save your file with the .html extension. You can close Notepad and find the file in the folder where you saved it — it will have a small browser icon next to its name.

Creating a basic HTML file on Mac

Open TextEdit by pressing Command + Space, typing "TextEdit", and pressing Enter. A blank document appears. Before you type any code, you must change the format from Rich Text to Plain Text. Click Format in the menu bar and select "Make Plain Text".

Now type or paste your HTML code. When you are ready to save, press Command + S. A dialog box opens. Type your filename with the .html extension — for example, mypage.html. Choose a location like Desktop or Documents. TextEdit may ask whether you want to use the .html extension; click "Use .html".

Close TextEdit and look for your file in the folder where you saved it. The file icon will show a small browser symbol, indicating it is recognized as an HTML file.

What to put in your first HTML file

A complete HTML file has a basic structure that tells the browser how to interpret the content. The simplest working example looks like this:

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

The <!DOCTYPE html> line tells the browser this is an HTML5 file. The <head> section contains information about the page, like the title that appears in the browser tab. The <body> section holds the content the reader sees — headings, paragraphs, images, and links.

You can copy this structure, change "My Page" to whatever title you want, and replace the heading and paragraph with your own text. Save it as described above, and you have a working webpage.

Opening your HTML file in a browser

Once you have saved your file, open it in a web browser to see how it looks. The simplest way is to find the file in your file manager (File Explorer on Windows, Finder on Mac), then drag it directly into an open browser window. The browser will display the rendered page — the formatted text and layout created from your HTML code.

Alternatively, right-click the file, select "Open with", and choose your preferred browser from the list. If you want to set a default browser, right-click, choose "Open with" again, select the browser, and check the box that says "Always use this app".

If you edit the HTML file later, save your changes in the text editor, then refresh the browser window (press F5 or Ctrl+R on Windows, Command+R on Mac) to see the updates.

Common mistakes that prevent HTML files from working

The most frequent problem is saving the file as .txt instead of .html. If you see your code displayed as plain text in the browser instead of formatted content, the file extension is wrong. Go back to your text editor, use Save As, and explicitly type the .html extension in the filename.

Another common issue is using a rich text editor like Microsoft Word or Google Docs. These programs add invisible formatting codes that break HTML. Always use a plain text editor — Notepad, TextEdit, gedit, or VS Code all work. If you have already typed code in Word, copy the text, paste it into Notepad, and save it as .html from there.

Typos in HTML tags also cause problems. Tags must be spelled exactly — <h1> works, but <h1 > with a space before the closing bracket does not. If your page looks wrong or blank, check that opening and closing tags match and that you have not accidentally deleted any angle brackets.

Organizing multiple HTML files in a folder

As you create more HTML files, keep them in a dedicated folder so they stay organized. Create a new folder on your Desktop or in Documents — call it something like "My Webpages" or "HTML Projects". Save all your HTML files inside this folder.

If your HTML files link to images or other files, keep those in the same folder or in subfolders inside it. For example, you might have a folder structure like: My Webpages (main folder) containing index.html, about.html, and a subfolder called "images" with your picture files. This way, when you move the entire folder to a different location or share it with someone else, all the files stay connected and links do not break.

Frequently Asked Questions

Can I use Word or Google Docs to write HTML?

No. Word and Google Docs add hidden formatting that breaks HTML code. Always use a plain text editor like Notepad, TextEdit, gedit, or VS Code. If you have already written code in Word, copy the text, paste it into Notepad, and save it as .html from there.

What is the difference between .html and .htm?

Both extensions work identically. .html is more common on modern systems, but .htm exists because older Windows versions limited filenames to three-letter extensions. Use .html unless you have a specific reason not to.

Do I need to upload my HTML file to the internet for it to work?

No. You can open and view HTML files directly on your computer by dragging them into a browser. Uploading to a web server is only necessary if you want other people to visit your page on the internet.

Why does my HTML file open in Notepad instead of the browser?

Windows is treating it as a text file rather than an HTML file. Right-click the file, select "Open with", choose your browser, and check "Always use this app". If that does not work, rename the file to make sure it ends in .html, not .txt.

Can I edit my HTML file after I save it?

Yes. Right-click the file, select "Open with", and choose your text editor. Make your changes, save the file, then refresh the browser window to see the updates.