Guide
Your HTML file shows code instead of the page
If you see <!DOCTYPE html> and tags instead of the page, the app that opened the file is treating it as text. The file is usually fine. It needs a browser.
By the ShareHTML team. Updated .
The usual causes
- A preview, not a browser: email, chat apps, Google Drive and Dropbox show the text of an .html file in their preview.
- A text editor opened it: Notepad, TextEdit and code editors show the code.
- The name is wrong: on Windows a file saved from Notepad can end up as
page.html.txt. Turn on file name extensions in File Explorer, then rename it. - A phone: phones open files in a viewer, not a browser. See iPhone and Android.
Open it as a page on a computer
- Save the file to your computer first, out of the email or chat.
- Right-click it, choose Open with, and pick Chrome, Edge, Safari or Firefox. Or drag the file onto an open browser window.
- If you made the file in TextEdit on a Mac, save it as plain text: Format, then Make Plain Text, before saving as .html.
So other people see the page
Send a link instead of the file. Drop the file on sharehtml.org, sign in with an emailed code, and share the link: it opens as a page in any browser, on any phone. More in how to send an HTML file.
Is it safe to open an HTML file?
An HTML file is a web page: it can run scripts and show forms. Opened from your computer, it cannot read your accounts on other websites, but it can show a fake sign-in page, and fake sign-in pages are often sent as .html attachments. Open files you expected, from people you know, and never type a password into a page that arrived as an attachment.
Questions
- Why does my HTML file open in Notepad?
- Windows has Notepad set as the app for .html files. Right-click, Open with, choose your browser, and tick "Always use this app".
- Why does Google Drive show my HTML as code?
- Drive previews files; it does not run web pages. Download it, or share a link.
- Why does the page open but look broken?
- It probably needs CSS, script or image files that are not next to it. Put them inside the HTML file, or ask the person who made it for one complete file.