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

前端 未结 10 685
广开言路
广开言路 2021-02-01 12:28

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

相关标签:
10条回答
  • 2021-02-01 13:07

    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.

    0 讨论(0)
  • 2021-02-01 13:07

    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

    0 讨论(0)
  • 2021-02-01 13:08

    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"

    0 讨论(0)
  • 2021-02-01 13:10

    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/, 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.

    0 讨论(0)
提交回复
热议问题