How to Open an HTML File on iPhone
To open an HTML file on iPhone, save it to the Files app and tap it to see a preview, or use the share sheet to open it in another app. Pages that load separate styles or images usually appear broken. The most reliable way is to put the page online, for example with HTMLpad, and open the link.
Computers open HTML files without fuss: double-click and the browser shows the page. iPhones and iPads are different. Files live inside apps, Safari does not browse your storage the way a desktop browser does, and the result is a lot of people staring at a file they cannot see properly. Here are the three ways that work, and which one to use.
Way 1: preview it in the Files app
This is the built-in route.
Apple's Files app is the hub for documents on iPhone, as MacMost's guide to the Files app shows in detail.
- Save the file to Files. If it came by email or message, tap and hold the attachment, then choose Save to Files. Pick a folder you will find again, such as iCloud Drive or On My iPhone.
- Open the Files app and go to that folder.
- Tap the file. Files shows a preview of the page.
For a simple, self-contained page this is often enough. You see the text and layout, and basic styling inside the file is applied.
The limits. An answer on Apple's support community puts it plainly: styling works when the CSS is embedded in the document, and links to other pages will not work because their paths assume a web server. Separate stylesheets, images in a folder and scripts that load other files often fail in a preview.
Way 2: open it with another app
From the Files preview, tap the share button and look for apps that can open HTML. Some code editors and HTML viewer apps from the App Store display HTML files as pages and also show the code.
This is useful if you work with HTML files often on your phone. For an occasional file, installing an app is more effort than the job needs, and the same limits apply: if the page depends on other files, the app needs those files too.
Way 3: open it as a link (most reliable)
Phones are built to open web pages, not web files. So turn the file into a page with an address.
- On a computer, open HTMLpad.org and paste or drop the HTML file into the editor.
- Check the preview and save. You get a link.
- Send the link to yourself, by message or email, or scan it with your phone.
- Tap the link on your iPhone. Safari opens the page like any website.
If you only have your phone, you can do the same thing in Safari: open HTMLpad.org, paste the HTML into the editor and save. Pasting long code on a phone is fiddly, but it works.
This is also the way to show the page to anyone else, on any device. I go into it in how to share an HTML file as a link.
Why pages break on iPhone
An HTML file is a set of instructions that often say "load this other file". On a computer, that other file sits in the same folder. On an iPhone, files are saved individually inside apps, so the folder structure the page expects usually does not exist.
The fix is either to make the page self-contained, with styles and scripts inside the HTML and images from public addresses, or to host it so everything is served from the web. The causes and fixes are the same as on a computer, covered in how to open an HTML file.
Viewing the code on iPhone
If you need the code rather than the page, open the file in a text or code editor app from the share sheet. To see the source of a page that is already online, an iPhone browser alone will not show it easily; the simplest route is to open the page on a computer and use View page source.
Frequently asked questions
Can Safari open HTML files from the Files app?
Not directly the way a desktop browser does. The Files app shows a preview of the HTML, and you can share the file to other apps. The most dependable way to see it in Safari is to open it from a web address.
Why does my HTML file show as plain text on iPhone?
The app you used is showing the code rather than rendering the page, or the file name does not end in .html. Save it to Files and tap it to preview, or host it and open the link.
How do I open an HTML email attachment on iPhone?
Tap and hold the attachment, save it to Files, then open it from Files. Be careful with HTML attachments you did not expect: they are a common way to deliver fake login pages, so never enter a password into one.
Does this work on iPad too?
Yes. iPad uses the same Files app and share sheet, so the same three ways apply, and the link route is just as reliable.
