What Is a .HTML File? (.html, .htm)
A .html or .htm file is a web page written in HyperText Markup Language. It is plain text with tags that describe headings, paragraphs, links, images and forms, which a web browser renders as a formatted page. Double-clicking an HTML file opens it in your default browser; any text editor can edit it.
- Extension
- .html, .htm
- Full name
- HyperText Markup Language
- Type
- Code and web file
- MIME type
- text/html
- Developed by
- WHATWG and W3C (originally Tim Berners-Lee)
About HTML files
HTML defines the structure of a web page; CSS adds styling and JavaScript adds behaviour, and both can be embedded in the same file or linked from separate files. A saved page that relies on external images, stylesheets and scripts will look broken if those files are not alongside it, which is why browsers save a matching _files folder or offer the single-file MHTML format.
The .htm extension is the same format, originating from systems limited to three-letter extensions. HTML files are small, usually a few kilobytes to a few hundred, unless images are embedded as data URIs. The text encoding should be UTF-8, declared with a meta charset tag, otherwise accented characters may display incorrectly.
HTML attachments in email deserve caution. Phishing messages often attach an HTML file that opens a convincing fake sign-in page locally, bypassing link scanners. Opening a page in a browser is sandboxed and generally safe, but never type passwords into a page that arrived as an attachment.
What HTML files are used for
- Web pages and website templates
- Saved copies of web pages for offline reading
- HTML email templates and newsletters
- Reports exported by software and analytics tools
- Documentation and help files
How to open a .html file
Windows
Double-click to view it in Edge or your default browser. To edit, right-click > Open with > Notepad, or use VS Code.
Mac
Double-click to view it in Safari. To edit the source, use VS Code or TextEdit with Settings > Open and Save > Display HTML files as HTML code instead of formatted text turned on.
iPhone and iPad
Tap the file in the Files app to see a rendered preview; use a code editor app from the App Store to view or edit the source.
Android
Open it with Chrome from Files by Google, or view the source in a text editor app.
How to convert a .html file
To make a PDF, open the page in any browser and choose Print > Save as PDF (Microsoft Print to PDF on Windows).
To get an editable document, open the HTML in Microsoft Word or LibreOffice Writer and save as .docx or .odt.
To save a complete page as one file, use Chrome or Edge's Save as > Webpage, Single File, which produces an .mht or .mhtml file.
Changing the extension in the file name does not convert the file. See how to change a file extension for when renaming is safe.
Naming and renaming HTML files
- Use lowercase letters, hyphens and no spaces (about-us.html) because file names become URLs, and spaces turn into %20.
- Name a site's home page index.html; web servers serve it automatically when a folder URL is requested.
- Choose .html or .htm and stick with it across a site, since links must match the extension exactly.
Renaming lots of .html files? See how to rename html files with ai, use the free online bulk renamer for patterns and numbering, or try File Renamer AI to name each file from what is inside it.
Related file types
A .mht or .mhtml file is a single-file web page archive. It bundles a page's HTML together with its images, stylesheets and other resources into one MIME-encoded file, so the page can be opened offline exactly as it was saved. Chrome and Edge open MHT files, and Word can open them too.
A .js file is a JavaScript source code file. Websites load JS files to add interactivity, and Node.js runs them as programs and tools on servers and computers. It is plain text you can read in any editor. Be careful: on Windows, double-clicking a .js file can run it as a script.
A .xml file is a plain text data file in Extensible Markup Language, which stores information in nested, self-describing tags such as <invoice> and <total>. It is used for data exchange, configuration, sitemaps, RSS feeds and document formats. Any text editor or browser can open an XML file.
A .json file is a plain text data file in JavaScript Object Notation, a lightweight format of names, values, lists and nested objects. It is the standard way web APIs exchange data and a common format for app settings, exports and configuration. Any text editor opens JSON, and browsers can display it nicely.
Frequently Asked Questions
What is the difference between .htm and .html?
None. They are the same format; .htm is a shorter extension from older systems that limited extensions to three letters.
Is it safe to open an HTML attachment?
Viewing it in a browser is sandboxed, but HTML attachments are a common phishing trick. Never enter a password into a page that came as an email attachment.
How do I edit an HTML file?
Open it in a plain text or code editor such as Notepad, VS Code or TextEdit in plain-text mode, edit the markup, save and refresh the browser.