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

What is the difference between .htm and .html files? cover image
  1. Home
  2. Answers
  3. What is the difference between .htm and .html files?

What’s the difference between .htm and .html? I’ve come across both these on the web. And can you advise on which one I should use?
Suraini Sami

Both .htm and .html are file extensions for HTML (HyperText Markup Language) files. So, to frame the question correctly for the benefit of all, what is the difference between these two file extensions?

Sponsored Links

However, before I get to the answer, here are some quick points:

.htm and .html are the same

There is absolutely no difference between .html and .htm files. They can be used interchangeably. Thus, you can rename a .html file to .htm and vice versa and the browser program will display it the same way.

The only difference is the file extension.

So why have two file extensions for the same kind of file? That, my friend, is because once upon a time, on many operating systems, file extensions could only be of three characters. This was especially true for Microsoft Windows, the most popular OS.

Thus, a lot of web pages created in “the good old days” (just a decade back or so) will have .htm file extension. And, I suppose, many old-schoolers would still be using .htm instead of .html.

Which is better and which one should you use?

Personally, I stopped using the three letter file extensions long time back and suggest you do the same. .htm seems a bit ancient in my opinion.

Finally, here is another bit of information. Files with .html or .htm extension may contain server-side code too. Thus, one can put PHP code and have it run with these files extensions. This is done by changing the server settings so that the files are parsed through the PHP interpreter. The web browser, however, will never show server-side code and present only HTML to the viewer.

Answers HTML Web Development