When I save a file with an .htm or .html extension, which one is correct and what is different?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
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:
So if you have any level of control over your server's default filenames, then this shouldn't be an issue.
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 asmyimage.html
and conversely, to deliver an HTML page asindex.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.
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
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