What an HTML file is and why you might have one
An HTML file is a text document that contains instructions for displaying a webpage. When you save a webpage to your computer or read one, you often get an HTML file. You might also receive one from a colleague, a course, or a template library. The file name ends in .html or .htm — both mean the same thing.
Unlike a Word document or PDF, an HTML file needs a web browser to display properly. Your browser reads the instructions inside the file and shows you the formatted page with text, images, links, and colors. Opening it the wrong way — like with Notepad — shows you the raw code instead of the finished page.
The good news: you almost certainly have what you need already. Every computer comes with at least one web browser, and that is all it takes.
Key Takeaways
- Double-click the HTML file to open it in your default browser, which is the fastest method for most people.
- If double-clicking does not work or opens the wrong program, right-click the file and choose "Open with" to pick a different browser.
- Common browsers that can open HTML files include Chrome, Firefox, Safari, and Edge — all free and already on most computers.
- Opening an HTML file in a text editor like Notepad shows you the code, not the webpage, so use a browser instead.
- HTML files saved to your computer work offline and do not need an internet connection to display.
The simplest way: double-click the file
Locate the HTML file on your computer. It will have a name followed by .html or .htm. Double-click it once. Your computer will open it in your default web browser — usually Chrome, Firefox, Safari, or Edge depending on what you use most often.
The webpage will display exactly as it would if you visited it online. You can click links, scroll, and interact with it normally. This is the method that works for most people without any extra steps.
If nothing happens when you double-click, or if it opens in a text editor showing code instead of a webpage, move to the next section.
When double-click does not work: using "Open with"
Right-click the HTML file. A menu will appear. Look for an option that says "Open with" or "Open with..." — the exact wording depends on whether you use Windows or Mac.
Click "Open with" and you will see a list of programs on your computer. Look for a web browser name: Chrome, Firefox, Safari, Microsoft Edge, or Internet Explorer. Click the one you want to use. The HTML file will open in that browser.
If you do not see any browser in the list, your computer may not have one installed beyond the default. Most computers come with at least one — Safari on Mac, Edge on Windows. If you want more options, you can read Chrome or Firefox for free from their official websites.
Setting a default browser for HTML files
If you find yourself using "Open with" every time, you can change which program opens HTML files by default. On Windows, right-click an HTML file, choose "Open with," then look for an option that says "Choose another app" or "Choose default program." Select your browser and check the box that says "Always use this app to open .html files." Click OK.
On Mac, right-click the HTML file and select "Get Info." Look for a section called "Open with." Click the dropdown menu, select your browser, then click "Change All." This sets that browser as the default for all HTML files.
After you set a default, double-clicking any HTML file will open it in that browser automatically.
What to do if you see code instead of a webpage
If the HTML file opened in Notepad, Notepad++, or another text editor, you are seeing the raw code that makes up the webpage. This happened because your computer is set to open HTML files with a text editor by default. Close this window.
Right-click the HTML file and choose "Open with." Select a web browser from the list. If you want to prevent this from happening again, follow the steps in the previous section to set a browser as your default.
If you actually do need to see and edit the code, a text editor is the right tool. But for viewing the finished webpage, always use a browser.
Opening HTML files from the browser itself
You can also open an HTML file using your browser directly. Open your web browser, then use the keyboard shortcut Ctrl+O on Windows or Cmd+O on Mac. A file browser window will appear. Navigate to your HTML file, select it, and click "Open." The file will display in the browser.
This method is useful if you already have your browser open, or if you are having trouble with the "Open with" menu. The result is the same — your HTML file displays as a webpage.
Frequently Asked Questions
Do I need internet to open an HTML file?
No. HTML files stored on your computer display offline. However, if the HTML file contains links to images, videos, or other content hosted on the internet, those parts will not load without a connection. The text and layout will still show.
Can I edit an HTML file after opening it in a browser?
Not directly through the browser. To edit the code, you need to open the file in a text editor like Notepad, Notepad++, or Visual Studio Code. After you make changes and save, you can refresh the browser to see the updates.
Why does my HTML file open in the wrong program?
Your computer is set to open HTML files with that program by default. Right-click the file, choose "Open with," select a web browser, and check the box to make it the default. Future HTML files will open in that browser.
What is the difference between .html and .htm?
There is no practical difference. Both are HTML files and open the same way in any browser. The .htm extension is older and was used when some systems limited file extensions to three letters. Modern computers use .html, but both work identically.
Can I open an HTML file on my phone?
Yes. On iPhone, use Safari or another browser app. On Android, use Chrome or another browser app. Use your file manager to locate the HTML file, then tap it. It will open in your default browser just like on a computer.