What exactly is the difference between .html and .htm?

 What exactly is the difference between .html and .htm?

All of the pages on the World Wide Web have been made with HTML. HTML files come with two basic extensions, .htm and .html.. There are a few points where these two HTML extensions (.htm and .html) differ. In this article, we will be going through each of the differences to help you understand whether you should use one or the other.

So, what exactly is HTML?
HTML stands for HyperText Markup Language and is used to develop web pages. This language is used because all web browsers (Chrome, Safari, Firefox and more) can interpret this language and renders it to us as a web page. HTML also assists in the formatting of several programming languages such as PHP and Javascript.

HTML is made up of several elements inside the opening and closing HTML tags. The data between these tags is where page content is implemented, including images, text, videos, forms and other forms of content. These elements of HTML are the building blocks of all websites, below is an example of what the barebones structure of an HTML webpage looks like.


While .htm and .html files are basically the same and can be used interchangeably, it is in the details where the differences lie. The lack of the letter ‘l’ in “.htm” is a holdover from the time when file systems relied on having 3 letter extensions.

Differences in Details:
So, why was “.html” introduced? In the past, file extensions on many operating systems could only be supported by up to three characters. One of the most prolific operating systems that supported three characters was Microsoft Windows’ DOS/16-bit operating system. Most new systems can handle 4 character file extensions and can be setup to understand both .htm and .html.

The elements of HTML are the building blocks of interactive web pages. HTML provides the means to create several organized and structured documents. This is done by denoting several structural semantics for text such as headings, paragraphs, lists, and other items. In recent times, webpages are rarely made with HTML, instead, Javascript is used.

In terms of usability, the .html extension is widely used and can support moat new operating systems while the .htm extension is only needed for extremely out of date legacy systems.

Both .html and .htm extensions can contain server-side code that allows PHP to run with these extensions. This is done by changing the server settings, the files get parsed through the PHP interpreter. The viewer does not see any server-side code as they’re only shown the HTML version when inspecting a web page.

If you have .htm files on your website, changing the extension to .html is generally harmless, though you may lose “link juice”, as Google will see it as a different page, though you probably shouldn’t have URLS ending in a file extension in 2019.

One final difference is how web servers handle priority. If you have index.htm and index.html, some may pick one over the other. Others may not recognise .htm for your index page (or 404, 503 pages). A relatively minor thing, but worth mentioning.

Summing things up
Long story short, both .html and .htm are webpage filename extensions with slight differences that have been created due to advancements in operating systems. In today’s technical climate, it’s recommended you use the .html extension. You probably don’t need DOS compatibility anyway.

If you’re a web developer yourself and would like to keep updated with the latest and most useful version of HTML, read this piece from the web development company CodeClouds, pointing out 10 reasons why you should switch to HTML5.

Chris Jorioso

Related post