.htm 或 .html 扩展名 - 哪一个是正确的,有什么不同?

发布于 2024-07-05 20:19:12 字数 47 浏览 8 评论 0原文

当我保存扩展名为 .htm 或 .html 的文件时,哪个是正确的,有什么不同?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

腹黑女流氓 2024-07-12 20:19:12

两者都没有错,只是偏好问题。 传统上,MS 软件默认使用 htm,而 *nix 更喜欢 html

正如下面所指出的,.htm 传统是从 win 3.xx 延续下来的,其中文件扩展名仅限于三个字符。

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.

月牙弯弯 2024-07-12 20:19:12

当您在本地保存文件时,差异并不重要 - 您的本地系统可能会将这两个文件扩展名视为可互换,以便由浏览器加载。 其原因是历史上基于 Windows 的系统使用 3 个字母扩展名 (htm),而基于 Unix 的系统使用 4 个字母 (html)。

在服务器端,提供默认文件名:

两个扩展名之间可能存在差异的一种情况是服务器的默认文件名。 当从服务器请求未指定文件名的 URL 时,例如 http://www. domain.dom/dirname/,服务器从请求的 URL 返回一个与默认文件名匹配的文件。 常见默认文件名的示例包括“index.html”、“index.htm”、“default.html”、“default” .htm”等。但是,管理员可以将服务器的默认文件名设为他/她想要的任何名称。

请注意,服务器通常配置多个默认文件名。

因此,如果您对服务器的默认文件名有任何级别的控制,那么这应该不是问题。

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.

晚风撩人 2024-07-12 20:19:12

主要是字数不同。

“.htm”带有 Microsoft 操作系统的味道,其中文件系统历来将文件扩展名(点后的文件名部分)限制为 3 个字符。

“.html”带有 Un*x 操作系统的味道,该操作系统没有此限制,并且用于当时所有严肃的互联网工作。

从实用上讲,两者是等效的。

差异在于文化。 有些人认为“.html”更正确。 这些人往往看不起微软操作系统,并认为“.htm”是对其局限性的不雅观提醒。

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.

隔纱相望 2024-07-12 20:19:12

另请注意,作为 URI 的一部分,文件扩展名不起任何作用。 事实上,它甚至不是一个文件扩展名,只是看起来像一个。 由 URI 标识的资源类型编码在其名称中。 相反,它由 Content-Type HTTP 标头字段决定。 将位图图片传递为 myimage.html 是完全合法的(但可能有点愚蠢),反之,将 HTML 页面传递为 index.png 是完全合法的(但可能有点愚蠢)。 这也是为什么有人认为文件扩展名根本不应该成为 URI 的一部分的原因。

Tim Berners-Lee 爵士在超文本样式:酷 URI 不会改变中详细阐述了这一点。

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.

少跟Wǒ拽 2024-07-12 20:19:12

就我个人而言,我更喜欢 .html,但正如其他人所说,两者都可以。

只要确保只使用一个即可。 切勿两者都在同一个网站上!
mypage.html 的链接与 mypage.htm 的链接不同

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

半步萧音过轻尘 2024-07-12 20:19:12

我使用.htm。 我猜打字少了。 或者也许这是我的 Windows 偏见。

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

陌上芳菲 2024-07-12 20:19:12

两者的工作方式相同,但有关技术和非技术参考,请在此处查找,
http://www.sightspecic.com/~mosh/www_faq/ext.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

毅然前行 2024-07-12 20:19:12

在过去,两者都是正确的,文件扩展名的长度不得超过 3 个字符。

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

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

情泪▽动烟 2024-07-12 20:19:12

我个人更喜欢 .html,因为它的名字是“超文本标记语言”。 使用 .htm 是因为某些旧版本的 Windows 文件扩展名不能超过 3 个字符

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

≈。彩虹 2024-07-12 20:19:12

它们是完全可以互换的。 如果我正确理解历史,那么一开始正确的扩展名是 .html,但当 Windows 95 出现时,它只能处理 3 个字符的扩展名。

因此,根据某些标准或其他标准,.html 是正确的,但实际上并不重要(大多数时候......刚刚进行了快速谷歌搜索并发现了以下内容)

不过,有一个值得关注的领域,大多数主机服务器将要求您的默认起始页命名为“index.html”而不是“index.htm”

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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文