HTML File Extensions and Versions
HTML files on the web use a handful of file extensions: .html, .htm, .xhtml, and occasionally .shtml. The most common — and the only one you should use for new projects — is .html. But the story of how we got here involves the evolution from HTML to XHTML and finally to HTML5 (now simply called "HTML").
.html vs .htm
The .htm extension exists because of a limitation in early operating systems. MS-DOS and Windows 3.x restricted file extensions to three characters (the 8.3 filename convention). Web servers on those systems used .htm because .html was not possible.
Today there is no functional difference between .html and .htm. Both are served with the MIME type text/html. However, .html is the standard and should be used for all new files.
A Brief History of HTML Versions
| Version | Year | Key Features |
|---|---|---|
| HTML 1.0 | 1993 | Basic tags: headings, paragraphs, links, lists |
| HTML 2.0 | 1995 | Forms, tables (RFC 1866) |
| HTML 3.2 | 1997 | Applets, text flow around images, tables for layout |
| HTML 4.01 | 1999 | CSS support, frames, scripting improvements |
| XHTML 1.0 | 2000 | HTML reformulated as XML |
| HTML5 | 2014 | Semantic elements, canvas, video, audio, local storage |
| HTML (Living) | 2019– | Continuously updated specification |
The XHTML Detour
In the early 2000s, the W3C pushed XHTML as the future of the web. XHTML reformulated HTML as strict XML, meaning:
- All tags must be closed (
<br />instead of<br>) - All tag names and attributes must be lowercase
- Attribute values must be quoted
- Documents must be well-formed XML
XHTML files used the .xhtml extension and were served as application/xhtml+xml. In practice, most developers served XHTML as text/html, which meant browsers parsed it as HTML anyway — defeating the purpose.
XHTML 2.0 was abandoned in 2009 when it became clear the web community preferred the pragmatic approach of HTML5 over XML strictness.
HTML5 and the Living Standard
HTML5 was developed by the WHATWG (Web Hypertext Application Technology Working Group) as a practical response to XHTML's strict approach. Key additions:
- Semantic elements:
<article>,<section>,<nav>,<header>,<footer>,<main>,<aside> - Multimedia:
<video>and<audio>without plugins - Graphics:
<canvas>for 2D drawing, plus SVG inline support - Forms: New input types (date, email, range, colour), validation attributes
- APIs: Web Storage, Web Workers, Geolocation, History, Drag and Drop
- Simplified doctype:
<!DOCTYPE html>
Since 2019, the specification is maintained as a "Living Standard" — there will be no HTML6. The spec is continuously updated, and new features are added incrementally.
The DOCTYPE Declaration
The doctype tells browsers which rendering mode to use:
<!-- HTML5 / Living Standard -->
<!DOCTYPE html>
<!-- HTML 4.01 Strict -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!-- XHTML 1.0 Strict -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Always use <!DOCTYPE html>. This triggers standards mode in all browsers and is the shortest valid doctype.
.shtml: Server-Side Includes
The .shtml extension was used with Apache's Server-Side Includes (SSI) feature. When a server encountered a .shtml file, it would process SSI directives like:
<!--#include virtual="/header.html" --> This was an early form of templating. SSI has been superseded by server-side languages (PHP, Node.js, Python) and static site generators. You should not use .shtml in new projects.
Modern Frameworks and Extensions
Many frameworks use custom extensions that compile to HTML:
| Extension | Framework | Notes |
|---|---|---|
| .svelte | Svelte / SvelteKit | Component files with HTML, CSS, and JS in one file |
| .jsx / .tsx | React | JavaScript/TypeScript with HTML-like JSX syntax |
| .vue | Vue.js | Single-file components |
| .astro | Astro | Island architecture components |
| .blade.php | Laravel | PHP templating engine |
| .ejs | Express.js | Embedded JavaScript templates |
| .njk | Nunjucks | Mozilla's templating language |
All of these ultimately produce .html output that browsers consume.
Best Practices for 2026
- Use
.htmlas your file extension (not.htmor.xhtml) - Use
<!DOCTYPE html>— always - Include
<html lang="en">(or appropriate language code) - Use semantic elements for document structure
- Set
<meta charset="utf-8">as the first element in<head> - Set
<meta name="viewport" content="width=device-width, initial-scale=1">for responsive design
Frequently Asked Questions
Is HTML5 still the right term?
Technically, the specification is now just called "HTML" (the WHATWG Living Standard). However, "HTML5" is still widely understood and often used to distinguish modern HTML from HTML 4.01. Both terms refer to the same thing in practice.
Can I use .html for XHTML content?
Yes, but there is no benefit. If you serve XHTML as text/html, browsers parse it as HTML anyway. If you serve it as application/xhtml+xml, a single well-formedness error will cause the page to fail entirely. Use standard HTML.
Does the file extension affect SEO?
No. Search engines care about content, structure, and metadata — not file extensions. Many modern sites use no file extensions in URLs at all (e.g., /about instead of /about.html).