The short answer
- HTML is a markup document format that describes web content and supports dynamic applications, but opening a file in a browser can execute scripts.
- To display a trusted HTML or HTM file, choose a browser in your device's file-opening menu. On Windows and Mac, choose a text or HTML editor when you want the source instead of the rendered page. On a phone, available opening options depend on the file manager and installed apps.
- Treat unfamiliar HTML as high-risk active content. Scripts can expose information or credentials, and disabling scripts does not eliminate every risk. IANA also describes network probing through combinations involving images. Untrusted web content needs a separate origin from sensitive content. See the [IANA security considerations](https://www.iana.org/assignments/media-types/text/html).
HTML files: opening, source code and safety
HTML means HyperText Markup Language. It organizes document meaning through elements, tags and attributes. Its current specification is the [WHATWG HTML Living Standard](https://html.spec.whatwg.org/multipage/introduction.html). Both .html and .htm are common extensions; the registered media type is text/html.
For a static copy such as PDF, choose a tool that explicitly supports HTML input and the required output. Because HTML scripts provide interactivity, a representation that does not execute those scripts cannot be assumed to preserve it. Parsing and exporting HTML can also discard or move some whitespace; keep the original if exact source preservation matters.
How to open it
To display a trusted HTML or HTM file, choose a browser in your device's file-opening menu. On Windows and Mac, choose a text or HTML editor when you want the source instead of the rendered page. On a phone, available opening options depend on the file manager and installed apps.
To display a trusted HTML or HTM file, choose a browser in your device's file-opening menu. On Windows and Mac, choose a text or HTML editor when you want the source instead of the rendered page. On a phone, available opening options depend on the file manager and installed apps.
For a static copy such as PDF, choose a tool that explicitly supports HTML input and the required output. Because HTML scripts provide interactivity, a representation that does not execute those scripts cannot be assumed to preserve it. Parsing and exporting HTML can also discard or move some whitespace; keep the original if exact source preservation matters.
File safety
Treat unfamiliar HTML as high-risk active content. Scripts can expose information or credentials, and disabling scripts does not eliminate every risk. IANA also describes network probing through combinations involving images. Untrusted web content needs a separate origin from sensitive content. See the [IANA security considerations](https://www.iana.org/assignments/media-types/text/html).
An unknown sender, a name ending in two extensions, or contents that do not match the extension — check before you open it.
Converting it
For a static copy such as PDF, choose a tool that explicitly supports HTML input and the required output. Because HTML scripts provide interactivity, a representation that does not execute those scripts cannot be assumed to preserve it. Parsing and exporting HTML can also discard or move some whitespace; keep the original if exact source preservation matters.
Convert a copy, never the original, then compare quality, metadata, and layout against what you started with.
Common questions
What is an HTML file used for?
An HTML file describes the meaning and structure of web content using elements and attributes. It can also support dynamic applications. Common extensions are .html and .htm, and its media type is text/html.
How do I open an HTML file on Windows?
Use the file's Open with menu to select a browser for a trusted file. Choose a text or HTML editor to inspect the source. Browser rendering can execute scripts, so assess unfamiliar files before opening them.
How do I open an HTML file on Mac?
Use the file's Open With menu to select a browser for page display or a text or HTML editor for source inspection.
How do I open an HTML file on a phone?
Check the file manager's opening options for a browser or HTML-capable app. Availability depends on the device and installed apps. Treat an unfamiliar file as active content.
Why does an HTML file display incorrectly in a browser?
Inspect its DOCTYPE: omission can trigger a rendering mode incompatible with parts of the standard. For a character display problem, inspect the encoding declaration as well. These checks do not establish the cause of every display error.
What is the difference between HTML and HTM file extensions?
Both .html and .htm are extensions for HTML documents. Choose based on the receiving system's requirements; the extension alone does not establish different content, safety or browser behavior.
Will converting HTML to PDF preserve interactivity?
Do not assume it will. HTML can use embedded or external scripts for interaction. If the conversion produces a static representation that does not execute those scripts, the original interaction cannot be assumed to survive.
What are the safety risks of an unfamiliar HTML file?
HTML can execute scripts associated with information leakage, credential leakage and web attacks. Disabling scripts does not remove every risk: IANA also describes image-related network probing. A recognizable extension or successful display is not proof of safety.
Does an HTML file have a fixed file signature?
No byte sequence uniquely identifies every HTML document, according to IANA. <!DOCTYPE html> must not be treated as a mandatory fixed signature. DOCTYPE affects rendering mode, but its presence does not prove safety or validity.
How can I view HTML source code without changing the original?
Open the original file in a text or HTML editor and inspect it without saving changes. Do not rely on a browser-parsed export for exact source preservation: some whitespace around the document element can be discarded or moved.
Related formats
Sources
IANA — text/html Media Type Registration · IANA
HTML Standard — Introduction · WHATWG
HTML Standard — The HTML Syntax · WHATWG
HTML Standard — Scripting · WHATWG