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 or a web development program to create one. Any text editor that comes with your computer — Notepad on Windows, TextEdit on Mac, or gedit on Linux — can create an HTML file. The browser reads the text you write, recognizes the HTML tags (the words in angle brackets like <p> and <h1>), and turns them into a formatted page you see on screen.

The steps are the same whether you are building a single practice page or starting a larger project. You write the content and tags in your text editor, save the file with a .html extension instead of .txt, and then open it in your browser to see how it looks.

Key Takeaways

  • Open Notepad (Windows), TextEdit (Mac), or any plain text editor, and type or paste your HTML code into it.
  • Save the file with a name ending in .html, not .txt — this tells your computer it is a webpage, not plain text.
  • Open the saved file in any web browser by double-clicking it or dragging it into the browser window to see your page.
  • Edit the file anytime by right-clicking it, choosing "Open with" your text editor, making changes, and saving again.

Creating an HTML file on Windows using Notepad

Open Notepad by pressing the Windows key, typing "Notepad", and clicking the result. A blank window will open. Type or paste your HTML code directly into this window. A basic starting point looks 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 appears, type a filename followed by .html — for example, "mypage.html" or "index.html". Make sure the Save as type dropdown shows "All Files" rather than "Text Documents (.txt)". If it says "Text Documents", click the dropdown and change it. Choose where you want to save the file (your Desktop or Documents folder is fine), then click Save.

Your file is now saved as an HTML file. You can close Notepad. To see your webpage, find the file you just saved, double-click it, and it will open in your default web browser.

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 anything, you must change TextEdit from rich text mode to plain text mode. Go to the Format menu and click "Make Plain Text". This step is important — 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 structure shown above. When you are ready to save, press Command + S or go to File and click Save. A dialog will appear asking for a filename. Type your filename followed by .html — for example, "mypage.html". Make sure the file extension is .html, not .txt. Choose where to save it, then click Save.

Close TextEdit and find your saved file. Double-click it and it will open in your default web browser, showing your formatted page.

Opening your HTML file in a web browser

Once your file is saved with a .html extension, you have two ways to view it. The first is to find the file on your computer and double-click it — your browser will open automatically and display the page. The second is to open your browser first, then drag and drop the HTML file into the browser window.

You can also right-click the file, select "Open with", and choose which browser you want to use. This is useful if you want to test your page in multiple browsers (Chrome, Firefox, Safari, Edge) to see if it looks the same in each one.

Every time you make changes to the HTML file in your text editor and save it, you can refresh the browser page (usually by pressing F5 or Ctrl+R on Windows, or Command+R on Mac) to see your updates.

Editing your HTML file after you create it

To make changes to your HTML file, you do not need to create a new one. Right-click the file, select "Open with", and choose your text editor (Notepad, TextEdit, or whatever you used to create it). The file will open in your editor showing all the code. Make your changes, then save the file using File > Save or Ctrl+S (Windows) or Command+S (Mac).

After you save, switch back to your browser and refresh the page. You will see your changes immediately. This cycle — edit in the text editor, save, refresh in the browser — is how you build and test webpages.

Choosing a filename and location for your HTML file

Name your file something descriptive that ends in .html. Common examples are "index.html" (often used for a homepage), "about.html", "contact.html", or "mypage.html". Avoid spaces and special characters in filenames — use hyphens or underscores instead if you need to separate words. For example, use "my-page.html" instead of "my page.html".

Save your file somewhere you can find it easily, like your Desktop or a Documents folder. If you plan to create multiple HTML files that work together, create a single folder for your project and save all the files inside it. This keeps everything organized and makes it easier to link files to each other later.

Troubleshooting common problems when creating HTML files

If you save a file and it still opens as plain text instead of a formatted webpage, the file extension is probably wrong. Right-click the file, select "Rename", and make sure it ends in .html, not .txt. On Mac, if TextEdit added a .txt extension automatically, delete it and type .html instead. Save and try opening it again.

If your HTML code does not display correctly in the browser, check that you closed all your tags. Every opening tag like <p> needs a closing tag like </p>. Missing closing tags are the most common reason a page looks wrong. Open your file in the text editor, find the tag that is missing its closing partner, add it, save, and refresh the browser.

If you cannot find your saved file, check your Downloads folder or Desktop. On Windows, you can also press the Windows key and type the filename to search for it. On Mac, press Command + Space and type the filename. Once you find it, you can move it to a more permanent location like Documents.

Frequently Asked Questions

Do I need to buy software to create an HTML file?

No. Every computer comes with a text editor built in — Notepad on Windows or TextEdit on Mac. These are all you need to create and edit HTML files. Many people use free editors like Visual Studio Code or Sublime Text later on, but they are not required to start.

What is the difference between saving as .html and .txt?

A .txt file is plain text that your browser will not format. A .html file tells your browser to read the tags and display a formatted page. The content is identical, but the extension changes how your computer treats the file.

Can I create an HTML file on my phone or tablet?

Yes, but it is more difficult. You need a text editor app that saves plain text files with a .html extension. Apps like Textastic (iOS) or Jota+ (Android) can do this. Most people find it easier to use a computer for HTML work.

What happens if I open an HTML file in a text editor instead of a browser?

You will see all the code and tags, not the formatted page. This is actually useful when you want to edit the file. To see the formatted page, open the file in your browser instead.

Can I create an HTML file without knowing any HTML code?

You can create the file itself, but you need some HTML code to put in it. Start with the basic structure shown in this guide, then add your own text between the tags. There are many free HTML tutorials online that teach you what each tag does.