255

What is the difference between the .htm and .html file extension?

Why there are two of them?

Which is correct?

Aryan Beezadhur
  • 4,503
  • 4
  • 21
  • 42
CannibalSmith
  • 4,742
  • 10
  • 44
  • 52

11 Answers11

281

The short answer

There is none. They are exactly the same.

The long answer

Both .htm and .html are exactly the same and will work in the same way. The choice is down to personal preference, provided you’re consistent with your file naming you won’t have a problem with either.

Depending on the configuration of the web server, one of the file types will take precedence over the other. This should not be an issue since it’s unlikely that you’ll have both index.htm and index.html sitting in the same folder.

We always use the shorter .htm for our file names since file extensions are typically 3 characters long.

AND MORE ON: http://www.sightspecific.com/~mosh/WWW_FAQ/ext.html or http://www.sightspecific.com/~mosh/WWW_FAQ/ext.htm

I think I should add this part here:
There is one single slight difference between .htm and .html files. Consider a path in your server like: mydomain.example/myfolder. If you create an index.htm file inside that folder and you open that like this: mydomain.example/myfolder/, it will go crazy and spit out your files as it is in your server,An image describing the bug with .htm files
but if you create an index.html file in there and open that directory in your browser, it will load that file. I tested this on my VPS and found this. Maybe you could somehow set your server to load index.htm files by default, but I guess the .html file is the default file type for browsers to open in each directory.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
joe
  • 34,529
  • 29
  • 100
  • 137
  • 37
    Not necessarily personal preference - many [microcontrollers](http://arduino.cc/en/Reference/SDCardNotes) and embedded systems use an [8.3 naming convention](http://en.wikipedia.org/wiki/8.3_filename). – emc Sep 28 '13 at 05:01
  • 3
    Most web servers don't care (Apache, IIS, Nginx, ...). A very few actually do care (these are often limited by the OS, file system, or are extremely old). It is only by default that the web server host the same filename and directory structure that is set locally. The metadata that is sent with the webpage defines what type of a file it is. The web server does not need to pass an extension. But it sometimes does. See - URL Rewrite. – TamusJRoyce Dec 29 '16 at 21:40
  • 6
    "since file extensions are typically 3 characters long" except for `.js` and `.json` which are two of the most frequently used web file extensions. – AJP Jan 24 '21 at 19:12
  • 3
    The sightspecific.com link is dead :( – Vthechamp Feb 17 '21 at 12:10
116

Neither!

If you're asking; "what would a website visitor rather type, htm or html" - it's much better to give them a nice descriptive URL with no extension. If they get used to going to yoursite/contact.html and you change it to yoursite/contact.php you've broken that link. If you use yoursite/contact/ then there's no problem when you switch technology.

Fenton
  • 241,084
  • 71
  • 387
  • 401
  • 82
    +1. I always feel like I've traveled back in time when I see resources ending in `.html` on a modern website. – Grant Wagner Jul 22 '09 at 16:32
  • 4
    That's quite a good idea. Still, isn't there a distinction between the storage and the url? Shouldn't that be the server's job? – xtofl Jul 24 '09 at 15:08
  • 2
    It's up to you how you achive yoursite/contact/ - I use mod_rewrite on Apache or URL routing on Windows. Some people use folder structures, which isn't ideal - but can still easily be replaced with either mod_rewrite or URL routing later. – Fenton Jul 27 '09 at 07:47
  • Yes you should rewrite the url, but you still have to have something behind it. Anyway, +1. – i_am_jorf Aug 10 '09 at 18:43
  • 2
    Why the slash at the end? yoursite/contact is fine. – Flash Aug 29 '12 at 10:09
  • 3
    @Andrew - that's a matter of preference really. Do whichever you prefer. Many sites accept yoursite/contact but redirect it to yoursite/contact/ because they prefer it. – Fenton Aug 30 '12 at 08:17
  • for the love of static, use .html; it adds trust in my mind. – webjay Jun 25 '16 at 16:53
  • 4
    @GrantWagner - "I always feel like I've traveled back in time when I see resources ending in .html on a modern website." - One thing I love about this statement is that it is stated in July 2009! – waqasahmed Jan 01 '20 at 16:46
30

.html always for new files. .htm is a throwback to dos days.

DanDan
  • 10,462
  • 8
  • 53
  • 69
22

.html - DOS has been dead for a long time. But it doesn't really make much difference in the end.

Pavel Minaev
  • 99,783
  • 25
  • 219
  • 289
20

Same thing.. makes no difference at all... htm was used in the days where only 3 letter extensions were common.

waqasahmed
  • 3,555
  • 6
  • 32
  • 52
12

If you plan on putting the files on a machine supporting only 8.3 naming convention, you should limit the extension to 3 characters.

Otherwise, better choose the more descriptive .html version.

xtofl
  • 40,723
  • 12
  • 105
  • 192
5

I guess it's a little too late now however the only time it does make a difference is when you set up HTML signatures on MS Outlook (even 2010). It's just not able to handle .html extensions, only .htm

3

It's the same in terms of functionality and support. (most OS recognize both, most Search Engines recognize both)

For my everyday use, I choose .htm because it's shorter to type by 25%.

Wadih M.
  • 12,810
  • 7
  • 47
  • 57
2

Here is some food for thought.

If you had been using all .htm files on your website and now, for example, you have changed the editor that you are using, and your new editor is outputting all your files with the .html extension. When you re-publish your site to the server, it would seem to me that you could really hurt your SEO position/ranking as many of the links out there in the web, including Google, that were looking for the .htm and not the new .html for that same page. This assumes that you are still using the same page names from your old editor which would make sense.

Anyway... My point is, be careful not to loose that link juice you have build up. So I guess in this example, there is a reason to stick with .htm... But other then that as mentioned by everyone else they seem to be the same.

Please correct if I'm wrong.

The reason I mention all this is because this is what I was in the process of doing when it occurred to me I may be damaging the site SEO with the new editor.

The original editor was MS Front Page, which always outputted .htm, dead now, and the new editor "90 Second Web Builder 9" which outputs all .html files... Luckily, they must have thought about this and they included a way to change the output extension back to .htm

Anyway, that's my 2 cents... hope it helps someone..

TerryD
  • 1
  • 1
  • 1
    If your website URLs end in .htm or .html, you're doing it wrong. Semantic URLs are much more user-friendly and don't suffer from the problem you've described. There's no reason why you should expose your file extensions to your website's visitors. – rdb Jun 22 '19 at 13:11
1

Since nowadays, computers support widely any length as file type, the choice is now only personal. Back in the early days of Windows where only 3 letters where supported, you had to use .htm, but not anymore.

T0xicCode
  • 4,583
  • 2
  • 37
  • 50
  • 9
    you mean, "back in the early days of *Windows* where only 3 letters (in extensions) were supported". Unix and Mac OS (even pre-OS X) never had those limitations; we were using `.html` extensions from the very start. – Val Jul 22 '09 at 23:49
0

In short, they are exactly the same. If you notice the end of the URL, sometimes you'll see .htm and other times you'll see .html. It still refers to the Hyper-Text Markup Language.