HTML files open in your web browser, not in a text editor
An HTML file is a document written in code that your browser reads and turns into a webpage. When you double-click an HTML file on your computer, it should open in whatever browser you use — Chrome, Firefox, Safari, or Edge. If it opens in Notepad or another text editor instead, you can fix that in a few seconds by choosing the right program.
The file itself ends with .html or .htm (both mean the same thing). You might see these files when you download a webpage to read offline, when someone sends you a document they built in HTML, or when you download code you wrote yourself.
Key Takeaways
- Double-clicking an HTML file should open it in your web browser automatically, but if it opens in a text editor, you can change which program opens it.
- Right-click the file, choose "Open with," and select your browser from the list to open it the way you want.
- On Windows, you can set your browser as the default program for all HTML files so they always open in the browser.
- If you need to edit the code inside the HTML file, you can open it in Notepad, but viewing it requires a browser.
Opening an HTML file on Windows
On Windows, find the HTML file on your computer. It will have a small icon next to its name — usually a picture of a document or a browser logo. Double-click it. In most cases, it opens in your default browser right away.
If it opens in Notepad or Wordpad instead, right-click the file. A menu appears. Click "Open with" and then select your browser — Chrome, Firefox, Edge, or Safari if you have it installed. The file opens in that browser. If you want the browser to be the default for all HTML files from now on, look for an option that says "Always use this app to open .html files" or similar, and check that box before clicking.
Opening an HTML file on Mac
Find the HTML file in Finder. Right-click it (or hold Control and click). A menu appears. Select "Open With" and then choose your browser — Safari, Chrome, Firefox, or another option. The file opens in that browser.
To make your browser the default for all HTML files, right-click the file again, choose "Get Info," and look for a section called "Open with." Click the dropdown menu, select your browser, and then click "Change All." From then on, all HTML files open in that browser when you double-click them.
Dragging and dropping an HTML file into your browser
If you have your browser already open, you can drag an HTML file directly into it. Open your file manager (File Explorer on Windows, Finder on Mac) and locate the HTML file. Click and hold on the file, then drag it into an open browser window. Release the mouse. The file opens as a webpage in that browser tab.
This method works every time and does not require you to change any settings. It is useful if you only need to open one file and do not want to set a default program.
Using the browser's File menu to open an HTML file
Open your web browser. Click the menu button (three horizontal lines in the top corner for Chrome and Firefox, or the menu bar at the top for Safari and Edge). Look for an option that says "Open" or "Open File." Click it. A window appears asking you to choose a file from your computer.
Navigate to where your HTML file is stored, click on it to select it, and then click "Open" at the bottom of the window. The file opens in your browser as a webpage. This method works on all browsers and all operating systems.
What to do if the HTML file still will not open in your browser
If you have tried the steps above and the file still opens in a text editor, your browser may not be installed or may not be set up correctly. First, make sure you have a browser installed. Chrome, Firefox, Safari, and Edge are all free and available for download from their official websites.
If you have a browser installed but the file still will not open in it, try the drag-and-drop method: open your browser, then drag the HTML file directly into the browser window. If that does not work, use the browser's File menu to open the file (the method described above). Both of these approaches bypass the default program setting and force the browser to open the file.
Opening an HTML file to edit the code inside it
If you need to change the code in an HTML file, you need a text editor, not a browser. Right-click the HTML file and choose "Open with," then select Notepad (Windows), TextEdit (Mac), or another text editor. The code appears on screen, and you can edit it. When you save the file, the changes are stored.
After you edit and save the file, you can open it in your browser again to see how the changes look. Many people switch back and forth between a text editor (to change the code) and a browser (to see the result). If you plan to edit HTML files regularly, you might want to download a code editor like Visual Studio Code, which is free and designed specifically for this work.
Frequently Asked Questions
Why does my HTML file open in Notepad instead of my browser?
Your computer is set to open HTML files with Notepad by default. This is usually because Notepad was the first program to open an HTML file on your computer. Right-click the file, choose "Open with," select your browser, and check the box that says "Always use this app" to change the default.
Can I open an HTML file without downloading a browser?
No. You need a web browser to view an HTML file as a webpage. All computers come with at least one browser built in — Edge on Windows, Safari on Mac. If you want a different browser, you can download Chrome or Firefox for free from their websites.
What is the difference between opening an HTML file and viewing a website?
An HTML file on your computer is a single document that your browser reads and displays. A website is many HTML files (plus images, videos, and other files) stored on a server somewhere on the internet. When you visit a website, your browser downloads those files from the server and displays them. Opening a local HTML file works the same way, except the files are on your computer instead of the internet.
Can I open an HTML file on my phone?
Yes. On an iPhone, use Safari or another browser app. On Android, use Chrome or another browser app. Open the browser, tap the menu, look for "Open" or "Open File," and navigate to the HTML file on your phone. Some phones may require you to use a file manager app first to locate the file, then tap it to open it in your browser.
What if the HTML file is corrupted or will not display correctly?
Try opening it in a different browser. Sometimes a file displays differently in Chrome than in Firefox or Safari. If it still does not display correctly, the file itself may be damaged or incomplete. Try downloading it again from wherever you got it, or ask the person who sent it to you to send it again.