.htm与.html?哪种文件扩展名更正确? [英] .htm vs .html ? Which file extension naming is more correct?

查看:155
本文介绍了.htm与.html?哪种文件扩展名更正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该为HTML文件选择哪个文件扩展名?为什么呢?

Which file extension should I choose for my HTML files? And why?

推荐答案

简短答案

没有.它们是完全一样的.

There is none. They are exactly the same.

详细答案

.htm和.html完全相同,并且将以相同的方式工作.如果您与文件命名保持一致,则选择都不取决于个人喜好.

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.

根据Web服务器的配置,其中一种文件类型将优先于另一种文件类型.这应该不成问题,因为您不太可能将index.htm和index.html放在同一个文件夹中.

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.

我们通常使用较短的.htm作为文件名,因为文件扩展名通常为3个字符长.

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

以及更多信息: http://www.sightspecific.com/〜mosh/WWW_FAQ/ext.html http://www.sightspecific .com/〜mosh/WWW_FAQ/ext.htm

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

我想我应该在这里添加这部分:
.htm和.html文件之间只有一个细微的差别.考虑服务器中的路径,例如: mydomain.com/myfolder .如果您在该文件夹中创建一个 index.htm 文件并按以下方式打开该文件: mydomain.com/myfolder/,它会发疯并吐出文件在您的服务器中,
但是如果您在其中创建一个 index.html 文件并在浏览器中打开该目录,它将加载该文件. 我在VPS上进行了测试,发现了 也许您可以通过某种方式将服务器设置为默认加载index.htm文件,但是我想.html文件是浏览器在每个目录中打开的默认文件类型.

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.com/myfolder. If you create an index.htm file inside that folder and you open that like this:mydomain.com/myfolder/, it will goes crazy and spit out your files as it is in your server,
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.

这篇关于.htm与.html?哪种文件扩展名更正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆