.fw files.wiki
HTML

HTML Files

HyperText Markup Language

An .html file is a text-based web page written in HTML, often containing links to CSS, JavaScript, images, and other web assets.

HTML document

Most common
Developer
WHATWG; World Wide Web Consortium (W3C) historically
Category
Web Files
MIME type
text/html
Format
Text
First released
1991
Latest version
HTML Living Standard
Open standard
Yes

HTML template file with server-side or static-site templating syntax

Developer
Various template-engine developers
MIME type
text/html; often application-specific before rendering
Format
Text
Open standard
No

XHTML document using .html extension

Developer
World Wide Web Consortium (W3C)
MIME type
application/xhtml+xml; often text/html when served as HTML-compatible XHTML
Format
Text
First released
2000
Latest version
XHTML5 / HTML Living Standard XML serialization
Open standard
Yes

Open a .HTML file online

Reading file…

What is a .HTML file?

The typical .html file will be an HTML document, being the source which a web browser interprets and displays as a webpage. The current specification is what's termed WHATWG HTML Living Standard, which has its foundations established by the World Wide Web consortium. This HTML document comprises the content as well as formatting information, like titles or headings, paragraphs, forms, tables, links or anchors, data attributes or meta tags and pointers to CSS files, JavaScript files, images, fonts, videos or audio. Typical places that you can come across with .html files include downloadable web pages, help files for various softwares, generated documents from various documentation, generated static sites, tool reporting files, email archives as well as files saved locally using your web browser.

This historical .htm extension stands for basically the very same thing in the exact same format, which is used due to DOS, Windows 8.3 Filename support issues. Additionally, the older XML-based XHTML is also often associated with the .html filename, mainly if written as plain-old-html; the more reliable way would include syntax and/or namespace checks, as the correct MIME content type for strict XML XHTML documents will be "application/xhtml+xml". There are numerous cases where web frameworks also adopt the .html extension for HTML-like templates with the use of Django {% %}, Jinja {{ }}, Liquid, Handlebars, ERB or Go template syntax in these files. These template files will not be final browser-ready HTML until rendered. When seen with your text editor, there are certain initiators that you'll see like the "<!DOCTYPE HTML>, <html>, <head>or<body>" in an HTML file.

How to open a .HTML file

Open a .HTML file on Windows

  1. 1 Go to the folder with your file in File Explorer. Usually, downloaded files end up in Downloads.
  2. 2 Double-click your .HTML file if you have an app for .html files on your computer. In case it does not open, move on to step three.
  3. 3 Right-click your .HTML file -> select Open with -> Choose another app.
  4. 4 Choose Google Chrome in the list (Windows 11: choose Always). For Windows 10 -> put a check on "Always use this app to open .html files" and click OK.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for Windows

Open a .HTML file on macOS

  1. 1 In the Finder app, locate your .HTML file.
  2. 2 Just double-click your .HTML file in order to automatically launch the program which is connected with it.
  3. 3 Need another app on your Mac? Control-click the file (or right-click with a mouse). In the pop-up menu select Open With -> Google Chrome.
  4. 4 If it isn't in the list, choose Other… and find the application manually.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for macOS

Open a .HTML file on Linux

  1. 1 Launch your file manager. Depending on the desktop it may be named Files (GNOME), Dolphin (KDE Plasma), Nemo (Cinnamon) or Thunar (Xfce).
  2. 2 Double-click the file.
  3. 3 Or choose another program by right-clicking the file -> Open With -> Google Chrome.
  4. 4 Install Google Chrome (if it is not installed on your computer) from the software centre, repository or Flathub.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for Linux

Open a .HTML file on Android

  1. 1 Launch Files or another file management app.
  2. 2 In Downloads, find the .HTML file and open it by tapping.
  3. 3 A list of apps capable of opening the file will be shown. Tap Google Chrome and press Always to permanently connect the file type with this app.
  4. 4 No apps able to open this file? Download Google Chrome from the Google Play Store.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for Android

Open a .HTML file on iPhone / iPad

  1. 1 Use the Files app and go to On My iPhone, iCloud Drive or Downloads.
  2. 2 Tap the .HTML file you want to open.
  3. 3 If the file can be opened by a built-in iOS app (supported format), it opens automatically.
  4. 4 Touch and hold the file to get the context menu -> choose Share -> select Google Chrome from the list of apps.
  5. 5 If there is no such option, download the app first from the App Store and then tap the document again.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for iPhone / iPad

Open a .HTML file online

  1. 1 Move to the online viewer at the top of this page.
  2. 2 Drag the file there or select it, and its contents will appear in your browser tab. The file is not uploaded.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for Online

More details about opening .HTML files

Double clicking the file extension .html usually opens this type of file through the default system browser (Microsoft Edge, Google Chrome, Mozilla Firefox, etc.). If the user desires using a different browser when opening .html files, he should select Right-click file -> Open with -> Choose another app and set up the file association. On the operating system macOS, browsers Safari, Chrome, Firefox and Edge can open these files. It is possible to select a new app for opening all types of the particular files from FindInfo->Open With. On operating systems Linux, Firefox, and Chrome or Chromium, the GNOME Web browser, or some other will open the html file, and mime types associations would most likely be established in the desktop file managers or via the xdg-mime command. On Android devices, browsers Google Chrome and Firefox would work, though it might depend on file permissions within the file manager. However, linked CSS styles, images, JavaScript and similar resources may not load due to limited access to the local file:// protocol.

The software for opening includes a lot more browsers and editors and their list would most certainly vary on various platforms. Among others, popular editing programs for opening and working with the HTML code include Visual Studio Code, Webstorm, sublime text editor and others supporting such features as validation, formatting, syntax high-lightening, and others. Another software able to work with HTML files would most likely be the libreoffice writer able to import files of many different formats (HTML, XHTML, XML, SVG). It is a good alternative for viewing files when it is needed to edit the document itself. This application is unable, however, to execute JS scripts and modern CSS styles properly.

Technical details

It represents a text, not a binary format, and does not have an exact single value for the magic number. For example, files can start with <!DOCTYPE html>, <html>, html comment tag, empty line(s), UTF-8 BOM, old markup without doctype, etc.

Common values of the MIME-type header include text/html (and text/html; charset=utf-8, which may be used by server). One can also set the document charset manually as part of the file as <meta charset=utf-8> at the top level of head section.

UTF-8 is usually used as a default for newly-created documents, while character encodings in browser are deduced using various methods including byte-order marks of documents, HTTP headers' information, <meta charset attribute, transmission default charsets, and older sniffer algorithms in parser. Typical file structure would contain a doctype, an html-root element, head with various data, and a body. Most common errors in syntax will be fixed by browsers automatically, i.e. incorrect tags closing/nesting/omissions, wrong syntax, etc.

Actual format is not compressed; gzip and brotli are normally used for transportation purposes; thus any non-zipped HTML on disk remains a textual document, while if located in an archive such as .zip, 7z, the document would not be directly visible. Styles are loaded using css link tag; js is included through script tags; image sources are loaded from img element's sources; other multimedia data - using audio/video tags; web fonts through CSS @font-face. Commonly included information would relate to file title, meta-description and open graph tags, twitter card data, canonical url of a document, viewport information, languages used, as well as JSON-LD structured data.

Typical size of a file on disk is from several kilobytes to several megabytes, usually due to additional CSS/Jscript/embedded SVG/image information encoded with Base64; XHTML serialization using a .html extension follows XML formatting (i.e. using tags, lowercase xmlns prefixes, xml headers etc.). Some html-files would include placeholder for template engine, e.g. jinja or django.

How to convert .HTML files

Use PDF in cases when a snapshot should be generated. The generation of snapshot in modern CSS can be better accomplished with modern Chromium/Chrome or in headless mode (wkhtmltopdf still seems quite handy here). The command line options can be e.g. like: chromium --headless --disable-gpu --print-to-pdf=output.pdf input.html, and for wkhtmltopdf: wkhtmltopdf input.html output.pdf. The approach requires access of HTML page to CSS, image, font sources. It can sometimes require page loading for capture of all JavaScript-generated data by Chromium browser.

Use the format supported in DOCX and ODT in case of word processors that require editing of output file. One way to convert is a generation with Pandoc into Word documents pandoc input.html -o output.docx, another - is generation of ODT file with LibreOffice via soffice --headless --convert-to odt input.html command. This approach supports better heading levels and their formatting, list markup, images and their captions, tables, links between different sections.

Generate files in Markdown format suitable for READMEs, static site conversions, Gitbook documents, and other texts stored in plain format with pandoc input.html -t gfm -o output.md command and in the text format with pandoc input.html -t plain -o output.txt. In contrast to PDF and DocX/Odt formats, none of style-related markup or scripting or CSS-driven layout and formating of table is conserved.

Share web-page and include in HTML the embedded CSS, fonts and images with following command and option: pandoc input.html --embed-resources --standalone -o output.html. Dynamic HTML content should be converted at the point of full-page generation in the browser. It does not capture server-side operations, user authentication details or sessions, and database contents of the dynamic pages.

Convert toToolCommand / note
PDF wkhtmltopdf wkhtmltopdf input.html output.pdf Renders the page to PDF; external CSS, images, and fonts must be reachable or local paths must be correct.
PDF Google Chrome or Chromium headless chromium --headless --disable-gpu --print-to-pdf=output.pdf input.html Uses a modern browser engine; useful for CSS-heavy pages, but interactive JavaScript state may not be captured unless the page finishes loading.
DOCX Pandoc pandoc input.html -o output.docx Preserves headings, lists, tables, links, and many images; complex CSS layout and scripts are not represented in Word format.
Markdown Pandoc pandoc input.html -t gfm -o output.md Good for extracting article-like content; forms, scripts, precise styling, and some table/layout details are lost.
Plain text Pandoc pandoc input.html -t plain -o output.txt Keeps readable text and link text but removes markup, styling, images, scripts, and semantic structure beyond simple formatting.
ODT LibreOffice headless soffice --headless --convert-to odt input.html Creates an editable OpenDocument Text file; browser-specific layout and dynamic content may differ.
Self-contained HTML Pandoc pandoc input.html --embed-resources --standalone -o output.html Embeds linked images, CSS, and other resources as data URIs where possible; may greatly increase file size.

Common problems and fixes

However, when the same .html file is shown as "This site can’t be reached," it usually contains some remote urls, including https:// or an assets folder. You have to restore the original folder structure or modify the paths for images and scripts according to the current situation. A blank page is generated due to some JavaScript syntax issues as HTML problems would show different results on the website; however, the Console and Network tabs of developer tools have more info regarding 404s and other syntax issues that have occurred within JavaScript. In case your site does not display styles, it may need investigation with relative paths, incorrect base href tag and even the browser cache. Checking in the Network tab whether your style was requested by the browser and what mime type returned could help to solve it. In case of getting a text output instead of a full HTML output, your page response is text/plain rather than the text/html; you have to change that in server-side headers into text/html as that could lead to the problem. When garbled text appeared on a website, it probably means the difference in the charset or encoding system between the server and HTML file; you have to save the file in UTF-8 format as well as change its meta tag to UTF-8 at head.

There are also cases of the downloading the file called "download.html" while it was just an access login page or an error page instead of the expected html; in case of receiving that type of document you can open it in a text editor for checking. As mentioned before, exports from email clients and reporting tools have huge amounts of style elements and other proprietary formats which may confuse a browser; therefore, it needs either re-export or clean-up with HTML tiding tools. If your .html opens not in a browser but somewhere else in your computer you have probably set another program as the default application or the wrong extension.

Security considerations

HTML pages allow running of JavaScript code on the page, fetching of remote resources, form submission and download start as well as using browser capabilities permitted for that page origin with corresponding permissions. Local HTML files generally work under file:// scheme with constraints; however, they are allowed to present absolute file path references, create networking requests and show spoofed sign-on pages. Be careful with opening non-trusted .html attachment in browsers. Attackers employ HTML smuggling, credential harvesting form, obfuscated scripts and dangerous download URLs. The browser restricts various activity types; however, crafted HTML page is able to reach bugs in the browser engine, PDF viewers, media decoders and extensions. It can store sensitive data in comment sections, JSON object inside of HTML pages, Google Analytics ID and absolute paths, save-page URL and inline images. Perform tests of suspicious HTML file with turning JavaScript capability off in isolated profile or VM.

History and versions

HTML has been designed from CERN itself, since Tim Berners-Lee created the idea of WWW at that place; the very earliest documents have been available around 1991. First known official document is HTML 2.0 released by IETF in 1995 as RFC 1866. It has provided us with basic facilities like forms and basic document structure. HTML 3.2 comes in W3C document in 1997. HTML 4.0 has come in 1997 and later HTML 4.01 came in 1999 separating structure and presentations and recommending use of CSS. In 2000 XHTML 1.0 came up which has converted HTML to XML form with recommendation in W3C Recommendation. HTML5 is recommended by W3C since 2014 adding many things such as new elements for better semanctic content handling, ability to add videos audios natively on the web page as HTML 5 elements and the canvas element for drawing on client browser and offline web storage among other new rules to parse a page. Since 2019 W3C and WHATWG agree for WHATWG HTML Living Standard as specifiation for html while .html remain an important part of web world.

.htm extension has the same meaning and functionality as .html. Use .html where possible, with the exception that compatibility needs may require usage of a 3-letter DOS or 8.3 filename format. Extensions .xht and .xhtml refer to XHTML and match up better with XML-based editing, validation, and processing software (since browsers are stricter when XHTML is served as XML). Extension .xml signifies a structured document in a very generic way. There are no implied page semantics as in HTML files; a stylesheet or transform must supply page semantics. CSS files referred to in HTML contain .css extension. JavaScript code for behavior goes into files .js. MHTML/MHT formats archive pages with all associated content together in one document; useful for single file archiving and less clear for simple viewing as an HTML format. Extensions .md/.markdown indicate plain text markup, .pdf files - print output.

Comments (0)

Replying to

No comments yet. Be the first to share your experience with this file type.