Key facts
- Plain text following the WHATWG HTML Living Standard; modern files start with <!DOCTYPE html>.
- MIME type is text/html; .htm is an older equivalent extension.
- Links to CSS, JavaScript and images by URL or relative path, so a single .html file often looks broken when moved without its folders.
- Browsers are forgiving and repair invalid markup silently, which can hide errors until layouts break.
- Created by hand, by CMSs and site generators, by email builders and by 'Save page as' in browsers.
How to open a .html file
Double-click to open it in Edge, Chrome or Firefox; right-click and choose Open with > VS Code or Notepad to edit the source.
Double-click to open it in Safari or another browser; open it in VS Code to edit, as TextEdit may display it rendered unless 'Display HTML files as HTML code' is enabled.
Run xdg-open page.html to view it in your default browser, or edit it with any text editor such as nano or VS Code.
Common problems and fixes
- Accented characters show as ΓΒ© or ?
- The file's encoding and its declared charset disagree. Save the file as UTF-8 and add <meta charset="utf-8"> as the first element inside <head>.
- Page opens without styling or images
- The CSS, image or script paths are relative and the folders were not copied, or they point to an absolute local path. Keep the page and its assets folder together and check paths in the browser's DevTools Network tab.
- Browser shows the raw HTML code instead of a page
- The file was saved as .txt, or the server sends it with Content-Type text/plain. Rename it to .html and make sure the server sends text/html.
- Layout breaks or content disappears
- An unclosed tag, wrong nesting or stray quote is confusing the parser. Run the markup through a validator and fix the first reported error first, as later ones often follow from it.
Often converted to or from: PDF, Markdown, plain text, DOCX, image (PNG)