An HTML file is a plain text file, saved with a .html (or .htm) extension, that contains HTML markup — the tags and content a browser reads and renders as a web page. Despite how visual and finished the result can look, the file itself is nothing more than text: no binary formatting, no proprietary structure, just characters a browser knows how to interpret.

What does an HTML file look like?

Opened in a text editor, an HTML file is a block of nested tags and content, something like this:

<!DOCTYPE html>
<html>
  <head>
    <title>Quarterly Report</title>
  </head>
  <body>
    <h1>Q3 Results</h1>
    <p>Revenue grew 12% compared to the prior quarter.</p>
  </body>
</html>

Opened in a browser, that same file renders as an actual page: a bold headline reading "Q3 Results" followed by a sentence of body text. The file and the rendered page are two views of the same thing — the source, and the result of the browser interpreting that source.

The basic structure of an HTML document

Nearly every HTML file follows the same skeleton:

  • <!DOCTYPE html> — declares the document as modern HTML.
  • <html> — the root element that wraps everything else.
  • <head> — metadata: the page <title>, character encoding, links to stylesheets, and information search engines and browsers use but that isn't displayed as body content.
  • <body> — the visible content: headings, paragraphs, images, links, and any other elements you can actually see or interact with.

You can learn more about what these individual tags do in our guide to what HTML is.

What does the .html extension mean?

The .html extension (or the shorter .htm, a holdover from operating systems that once limited extensions to three characters) simply tells your computer and your browser: "interpret this file as HTML and render it as a page." Nothing about the extension changes what's inside the file — it's the same plain text either way — it's purely a signal for how to open it.

How to open an HTML file

Double-clicking an .html file typically opens it in your system's default browser (Chrome, Safari, Firefox, Edge), showing you the rendered page, not the code. That's usually what you want if you're viewing a document someone sent you.

If you want to see the underlying markup instead, you have two easy options: right-click the file and choose "Open with" a plain text editor, or open the rendered page in a browser and use "View Page Source" (or the browser's developer tools) to inspect the HTML directly.

How to edit an HTML file

There are two very different ways to change an HTML file, and which one makes sense depends on what you're comfortable with:

  • Edit the code. Open the file in a text editor or a code editor, find the tag containing the content you want to change, and edit it directly. This works well if you're comfortable with HTML syntax, but a single misplaced character — an unclosed tag, a missing quote — can break the layout.
  • Edit the rendered page. A visual HTML editor opens the file and shows it exactly as it looks in a browser. You click directly on the text or image you want to change and edit it in place, the way you'd edit a slide in a presentation, with no tags visible at all.

The second approach has become especially relevant now that so many HTML files are generated by AI rather than handwritten — see what a WYSIWYG editor actually does for more on how that works.

HTML files vs other document formats

An HTML file differs from a .docx or .pdf in one fundamental way: it's rendered by a browser rather than opened by a specific application. That means it needs no installed software beyond a browser (which every device already has), it's typically much smaller than an equivalent Word or PDF file, and it can include interactive or responsive elements that adapt to screen size — something neither Word nor PDF do natively. For a closer look at the trade-offs, see our comparison of HTML, PDF and Word.

Can an HTML file contain CSS and JavaScript?

Yes, and most real-world HTML files do. Styling can live directly inside the file, either as inline style attributes on individual tags or inside a <style> block in the <head>. Behavior can be added with a <script> block, also usually in the <head> or at the end of the <body>. A single .html file with everything embedded — structure, styling and behavior all in one — is fully self-contained: you can email it, move it to another computer, or open it offline, and it will look and work exactly the same.

Can AI generate HTML files?

Yes — this is increasingly the default. When you ask an AI assistant like Claude or ChatGPT to draft a report, a proposal, a landing page, or a simple one-pager, it typically hands you back a complete .html file rather than a .docx. HTML is the format these models produce most fluently, it renders instantly with no software required, and it's easy to share as a single file or a link. The one gap has been editing: an AI-generated HTML file is easy for the model to produce but, until recently, awkward for a non-technical person to refine. That's exactly the gap a visual HTML editor is built to close.

FAQ

What does the .html extension mean?

It tells your computer and browser that the file contains HyperText Markup Language and should be interpreted and rendered as a web page. .htm is the same format, just a shorter extension left over from older filesystems that only allowed three-letter extensions.

How do I open an HTML file?

Double-click it, and it will usually open in your default browser, showing the rendered page rather than the code. To see the raw code, right-click the file and choose "Open with" a text editor, or open the browser's dev tools and view the page source.

Can I edit an HTML file without knowing how to code?

Yes. A visual HTML editor opens the file, shows it exactly as it renders in a browser, and lets you click on any text or image to change it directly, without opening the underlying tags at all.

Can an HTML file contain CSS and JavaScript?

Yes. Both can be written directly inside the file (inline styles, a <style> block, a <script> block) or linked from separate files. A single .html file with embedded CSS and JavaScript is fully self-contained and portable.