How to Open an HTML File

On a computer, a web browser opens an HTML file: in Chrome, press Ctrl+O (Command+O on a Mac) and select the file. Phones are harder, because Apple's and Google's help pages describe no way to open a saved HTML file in Safari or Chrome. The HTML viewer on this site is a web page, so a phone's browser can open it as well as a computer's, and it does not upload the file. It has not been tested on phones yet.

Updated

HTML viewer

1. In your browser, on any device

The viewer reads the file inside the browser, so the steps are the same on a computer and on a phone. It has been tested in Chrome, Firefox and WebKit (the engine of Safari) on a computer, not yet on phones.

  1. Open the HTML viewer in Safari, Chrome, Edge or Firefox.
  2. Drop the HTML file on the box, or press Choose a file and pick it. If the page has its own images and stylesheets, add its folder or a ZIP of it.
  3. Read the page. Scripts stay off until you choose Run scripts. Choose Code to see the HTML.
  4. To keep a copy anyone can open, choose Print / Save as PDF, or Download HTML for one self-contained HTML file.

The file is read by your browser and not sent to any server. How htmlviewer.app works explains how scripts and remote files are kept off until you choose them.

2. On an iPhone

Apple's iPhone guide says that when you open a file whose app is not installed, a preview opens in Quick Look. It does not say how Quick Look shows an HTML file, and it documents no way to open a saved HTML file in Safari. What Apple does document:

  1. Open the Files app. Files downloaded from the internet or from Mail are in Downloads: tap Browse, then Downloads.
  2. Tap the file to preview it, or touch and hold it, choose Open With, then choose an app.

To see the page in Safari, open the HTML viewer there, tap Choose a file and pick the file from Files. The viewer's file picker is set to HTML, HTM, XHTML, MHT, MHTML and ZIP files, and on a narrow screen the viewer shows the page and the code as two tabs. It has not been tested on an iPhone yet.

If the page has images and stylesheets beside it, make a ZIP first. Apple's guide: in Files, touch and hold the folder, then tap Compress. Then choose the ZIP in the viewer.

3. On an Android phone

Google's Android help says to open your device's Files app and tap a file to open it. It names no app that shows an HTML file as a page, and Chrome's Android help covers downloading, sharing and renaming a file, not opening a saved HTML file.

  1. Open Chrome and go to the HTML viewer.
  2. Tap Choose a file and pick the HTML file, or a ZIP of its folder.
  3. Read the page, and choose Run scripts if it needs them.

The viewer has not been tested on Android yet.

4. In Chrome on a computer

Google's list of Chrome keyboard shortcuts gives this way:

  1. Open Chrome.
  2. Press Ctrl+O on Windows or Linux, or Command+O on a Mac.
  3. Select the HTML file. It opens in Chrome.

To see the code of the page you have open, press Ctrl+U, or Command+Option+U on a Mac. Microsoft's list of Edge shortcuts gives the same Ctrl+O to open a file from your computer and Ctrl+U to view the source.

5. On Windows

Microsoft lists .htm and .html files as "Hypertext markup language page". To choose which app opens one:

  1. In File Explorer, right-click the HTML file.
  2. Select Open with, then Choose another app.
  3. Select a browser, such as Microsoft Edge or Chrome, to see the page, or Notepad to see the code.

Microsoft names Notepad among the apps that open any text format. It shows the code, not the page.

6. On a Mac

Apple's guide to choosing an app for a file gives these steps:

  1. In the Finder, Control-click the HTML file.
  2. Choose Open With, then choose Safari or another browser.

The same guide says you can also drag the file onto the app's icon in the Dock.

To read the code instead, use TextEdit: choose File > Open, select the file, click Show Options and select "Ignore rich text commands", then click Open. Without that option, Apple says, TextEdit shows the file as formatted text, as a browser would, and images may not appear.

Frequently asked questions

What programs can open an HTML file?

A web browser shows it as a page, and a text editor such as Notepad or TextEdit shows its code. On a phone, where neither is simple, the HTML viewer on htmlviewer.app is a web page the phone's browser can open; it has not been tested on phones yet.

How do I open an HTML file as a PDF?

Open it in the HTML viewer, choose Print / Save as PDF and pick "Save as PDF" as the printer in the print dialog. HTML to PDF has the details.

How do I open HTML in Notepad?

In File Explorer, right-click the file, select Open with, then Choose another app, and select Notepad. Notepad shows the code, not the page.