Html HTML5 `<link rel="shortcut icon" />`

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13211206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:41:48  来源:igfitidea点击:

HTML5 `<link rel="shortcut icon" />`

htmlfaviconrel

提问by chharvey

The WHATWG documentfor HTML5 says that the relattribute must contain values that are space-separated, and then it gives a table of allowed values.

HTML5的WHATWG 文档说该rel属性必须包含以空格分隔的值,然后它给出了一个允许值的表。

The attribue's value must be a set of space-separated tokens. The allowed keywords and their meanings...

属性的值必须是一组以空格分隔的标记。在允许的关键字和它们的含义......

The list of allowed keywords for the linkelement does not include shortcut, but it does include icon. So I'm looking at the all-too-well-known tag

link元素的允许关键字列表不包括shortcut,但确实包括icon。所以我在看那个众所周知的标签

<link rel="shortcut icon" href="/favicon.ico" />

and wondering if it is HTML5-compliant. Should I remove the keyword shortcutfrom this tag throughout my Website?

并想知道它是否符合 HTML5。我应该shortcut从整个网站的这个标签中删除关键字吗?

采纳答案by Alohci

From the same WHATWG document:

来自同一个 WHATWG 文档:

For historical reasons, the icon keyword may be preceded by the keyword "shortcut". If the "shortcut" keyword is present, it must be come immediately before the icon keyword and the two keywords must be separated by only a single U+0020 SPACE character.

由于历史原因,图标关键字之前可能会出现关键字“快捷方式”。如果存在“shortcut”关键字,则它必须紧接在图标关键字之前,并且两个关键字必须仅由一个 U+0020 空格字符分隔。

回答by Pablo Santamaria

Update: According to this page https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types

更新:根据此页面https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types

The shortcutlink type is often seen before icon, but this link type is non-conforming, ignored and web authors must not use it anymore.

快捷方式链接类型经常看到图标之前,但是这个链接类型是不符合要求的,忽略网页制作者不能再使用它。

Also, I don't see any references of shortcutin the W3C documentation, so I think it's better to leave it out. https://www.w3schools.com/tags/att_link_rel.asp

另外,我在 W3C 文档中没有看到任何对快捷方式的引用,因此我认为最好将其省略。https://www.w3schools.com/tags/att_link_rel.asp

回答by Josh Campbell

Although it is still in its experimental stage (because HTML5 dev is ongoing), the w3.org HTML5 Markup Validatoris a good online tool you can check out. I used it extensively about 6 months ago and it always gave back accurate HTML5 syntax reports.

尽管它仍处于试验阶段(因为 HTML5 开发正在进行中),但 w3.org HTML5 标记验证器是一个很好的在线工具,您可以查看。我在大约 6 个月前广泛使用它,它总是返回准确的 HTML5 语法报告。

回答by user4565320

I have tested this code on Crome, Firefox, "Internet explorer", "Edge". And the only thing didnt work was "Edge" when add Favorite from a page made on harddrive ex c:\temp\test.html

我已经在 Crome、Firefox、“Internet Explorer”、“Edge”上测试了这段代码。从硬盘驱动器上制作的页面添加收藏夹时,唯一不起作用的是“Edge”,例如 c:\temp\test.html

<html>
<head>
<META HTTP-EQUIV="Expires" CONTENT="0"><!-- Never cache page -->
<link  id="favicon" rel="shortcut icon" href="icon_32.ico">
</head>
<body>
...
</body>
</html>