What an HTML file is and why you might make one

An HTML file is a plain text document that tells a web browser what to display on a page. It contains instructions written in a language called HTML — short for HyperText Markup Language. When you open an HTML file in a browser like Chrome, Firefox, or Safari, the browser reads those instructions and shows you a formatted page with text, images, links, and other content.

You might create an HTML file if you want to build a straightforward website, save a page you wrote offline, or learn how web pages actually work. The file itself is just text, so you can create one with any text editor — the same program you would use to write a note or a document.

The key difference between an HTML file and a Word document or Google Doc is that HTML files are meant to be read by browsers, not by word processors. This makes them smaller, faster to load, and portable across any device with a browser.

Key Takeaways

  • An HTML file is a plain text document saved with the .html extension that tells a web browser what to display.
  • You can create an HTML file using any text editor — Notepad on Windows, TextEdit on Mac, or any other plain-text program.
  • The file must be saved with .html at the end of the filename, not .txt, or the browser will not recognize it as a web page.
  • Once saved, you can open the HTML file by double-clicking it or dragging it into a browser window to see how it looks.
  • HTML files are organized in folders just like any other file, so store them in a dedicated folder to keep your project together.

Opening a text editor and writing your first HTML

Start by opening a plain text editor. On Windows, this is Notepad — search for "Notepad" in the Start menu and click it. On Mac, open Finder, go to Applications, then Utilities, and double-click TextEdit. On Linux, use gedit or nano depending on your system.

Once the editor is open, type a straightforward HTML structure. Here is a basic example you can copy exactly:

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

Do not worry about what each line means right now — the important thing is that this is the basic skeleton every HTML page needs. The <title> tag is what appears in the browser tab. The <h1> tag creates a large heading. The <p> tag creates a paragraph of regular text.

If you are using TextEdit on Mac, go to Format menu and select "Make Plain Text" before you type anything. This prevents TextEdit from adding invisible formatting that will break your HTML file.

Saving the file with the correct extension

Saving with the right filename is the most important step. Go to File, then Save As. A dialog box will appear asking where you want to save the file and what to name it.

In the filename field, type a name followed by .html — for example, index.html or mypage.html. The .html at the end is called the file extension, and it tells your computer that this is an HTML file, not a plain text file. Without it, your browser will not recognize the file as a web page.

Choose a folder to save it in. If you are organizing files as described in the previous guide, create a new folder called "My Website" or "HTML Projects" and save your file there. This keeps all your HTML files in one place instead of scattered across your desktop or Documents folder.

On Windows, make sure the "Save as type" dropdown at the bottom of the dialog says "All Files" or "Text Documents", not "Word Document". On Mac, TextEdit will save as plain text by default once you have switched to plain text mode.

Opening your HTML file in a browser

Once you have saved the file, you can see what it looks like as a web page. Navigate to the folder where you saved your HTML file. Right-click on the file and select "Open with", then choose your browser — Chrome, Firefox, Safari, or Edge.

Alternatively, you can drag the HTML file directly into an open browser window. The browser will read the file and display it as a formatted page. You should see "Hello, World" as a large heading and "This is my first HTML page." as regular text below it.

If the file opens in Notepad or TextEdit instead of your browser, your computer did not recognize the .html extension. Go back and check that you saved the filename as something.html, not something.txt or something with no extension at all.

Editing and saving changes

To make changes to your HTML file, right-click on it and select "Open with" and choose your text editor — not your browser. Edit the text, then save the file using Ctrl+S on Windows or Command+S on Mac. You do not need to use "Save As" again unless you want to create a copy with a different name.

After you save changes in the text editor, switch to your browser and refresh the page using Ctrl+R on Windows or Command+R on Mac. The browser will reload the file and show your updates. This cycle — edit in the text editor, save, refresh in the browser — is how you build and test HTML pages.

Keep your text editor and browser open side by side so you can switch between them easily. This makes it faster to test changes without hunting for windows.

Organizing multiple HTML files in a folder

If you create more than one HTML file, store them all in the same folder. Create a folder called "My Website" or "HTML Project" and save all your .html files inside it. You can also create subfolders for images, stylesheets, or other resources your pages might need.

One file should be named index.html — this is the file that browsers look for first when you open a folder. If you later want to share your website or upload it to the internet, the server will automatically open index.html when someone visits your site.

Use clear, descriptive filenames like about.html, contact.html, or gallery.html instead of page1.html or untitled.html. This makes it easier to find the file you want to edit, especially as your project grows.

Common mistakes and how to avoid them

The most common mistake is saving the file with the wrong extension. If you type mypage.txt or just mypage with no extension, your browser will not recognize it as HTML. Always check that your filename ends with .html before you click Save.

Another mistake is using a word processor like Microsoft Word or Google Docs instead of a plain text editor. Word processors add invisible formatting codes that break HTML files. Always use Notepad, TextEdit, or a similar plain text editor.

If you edit your HTML file and the changes do not appear in the browser, you probably forgot to save the file in your text editor. Save first, then refresh the browser. If you still see the old version, try clearing your browser cache by pressing Ctrl+Shift+Delete on Windows or Command+Shift+Delete on Mac, then refresh again.

Do not use spaces or special characters in your filename — stick to letters, numbers, hyphens, and underscores. A filename like my-first-page.html works fine, but my first page.html or my&page.html can cause problems on some systems.

Frequently Asked Questions

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

Yes, but it is more difficult than on a computer. You need a text editor app that saves plain text files — most note-taking apps add formatting. Apps like Jota+ on Android or Textastic on iPad can save HTML files. Save the file with .html at the end, then open it in your phone's browser to test it.

What if I want to add images or colors to my HTML page?

You can add colors and images using HTML tags and CSS, which is a separate language that controls how pages look. Start by learning more HTML tags like <img> for images and <a> for links. There are many free tutorials online that show how to do this, and you create and edit them the same way — in a text editor, saved as .html, and opened in a browser.

Do I need internet to create and view an HTML file?

No. HTML files work completely offline. You can create them, edit them, and view them in your browser without any internet connection. If your HTML file contains links to websites or images from the internet, those links will not work offline, but the file itself and any local content will display fine.

Can I convert a Word document to HTML?

Yes. Most word processors, including Microsoft Word and Google Docs, have a "Save As" or "read" option that lets you save a document as HTML. Open your document, go to File, choose Save As or read, and select HTML as the format. The result will not be perfect — formatting may change — but it is faster than retyping everything.

What is the difference between .html and .htm?

Both extensions work the same way. .html is more common and is what you should use. The .htm extension exists because older Windows systems limited filenames to three-letter extensions, but modern computers support both. Stick with .html unless you have a specific reason not to.