.htm or .html extension - which one is correct and what is different?

HtmlNaming ConventionsFilenames

Html Problem Overview


When I save a file with an .htm or .html extension, which one is correct and what is different?

Html Solutions


Solution 1 - Html

Neither is wrong, it's a matter of preference. Traditionally, MS software uses htm by default, and *nix prefers html.

As oded pointed out below, the .htm tradition was carried over from win 3.xx, where file extensions were limited to three characters.

Solution 2 - Html

Mainly, the number of characters is different.

".htm" smells of Microsoft operating systems where the file system historically limited file name extensions (the part of the file name after the dot) to 3 characters.

".html" smells of Un*x operating systems that did not have this limitation and that were used for all the serious internet work at the time.

Pragmatically, the two are equivalent.

The difference is cultural. ".html" is regarded by some as more correct. The same people tend to look down at Microsoft operating systems and regard ".htm" as unsightly reminder of their limitations.

Solution 3 - Html

When you save the file locally, the difference doesn't matter - your local system will likely treat the two file extensions as interchangeable for loading by your browser. The reason for it is that historically Windows-based systems used 3 letter extensions (htm) and Unix-based systems the 4 letters (html).

On a server-side, there may be some differences when it comes to serving default filenames: >The one situation in which there may be a difference between the two extensions is that of a server's default filenames. When a URL that does not specify a filename is requested from a server, such as http://www.domain.dom/dirname/</code>;, the server returns a file from the requested URL that matches a default filename. Examples of common default filenames include "index.html," "index.htm," "default.html," "default.htm," etc. However, an administrator can make the server's default filename anything he/she so desires.

>Note that servers are often configured with more then one default filename.

So if you have any level of control over your server's default filenames, then this shouldn't be an issue.

Solution 4 - Html

Personally I prefer the .html but as other have said both will work.

Just make sure you only use one. Never both on the same site! link to mypage.html is not the same as link to mypage.htm

Solution 5 - Html

Also notice that as part of a URI, the file extension doesn't play any role. In fact, it isn't even a file extension, it just looks like one. The type of the resource identified by a URI is not encoded in its name. Instead, it is decided by the Content-Type HTTP header field. It's completely legitimate (but perhaps a bit stupid) to deliver a bitmap picture as myimage.html and conversely, to deliver an HTML page as index.png. This is also the reason why it is argued that file extensions shouldn't be part of URIs at all.

Sir Tim Berners-Lee elaborates on this in Hypertext Style: Cool URIs Don't Change.

Solution 6 - Html

They are completely interchangeable. If I understand the history properly then in the beginning the correct extension was .html but when Windows 95 came along it could only cope with 3 character extensions.

So .html is correct according to some standard or other but in practice it doesn't matter (most of the time...have just done a quick google search and found the following)

There is one area of concern though, most host servers will require your default starting page to be named as "index.html" and not as "index.htm"

Solution 7 - Html

I use .htm. Less typing I guess. Or perhaps it's my windows-bias.

Solution 8 - Html

Both are correct back in the past file extensions had to be a maximum of 3 characters long.

http://en.wikipedia.org/wiki/Filename_extension

Solution 9 - Html

Personally I prefer .html, since the name is "Hypertext markup language". .htm was used because certain legacy versions of windows could not have more than 3 characters in the file name extension

Solution 10 - Html

Both are working as same,but For the technical and non technical reference please find out here, http://www.sightspecific.com/~mosh/www_faq/ext.html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser21067View Question on Stackoverflow
Solution 1 - HtmlWilliam KellerView Answer on Stackoverflow
Solution 2 - HtmlddaaView Answer on Stackoverflow
Solution 3 - HtmlConroyPView Answer on Stackoverflow
Solution 4 - HtmlGeneView Answer on Stackoverflow
Solution 5 - HtmlKonrad RudolphView Answer on Stackoverflow
Solution 6 - HtmlWalkingRandomlyView Answer on Stackoverflow
Solution 7 - HtmlTundeyView Answer on Stackoverflow
Solution 8 - HtmlPaul WhelanView Answer on Stackoverflow
Solution 9 - HtmlAmandasaurusView Answer on Stackoverflow
Solution 10 - Htmluser693137View Answer on Stackoverflow