HTML5 `<link rel=“shortcut icon” />`

廉价感情. 提交于 2019-11-27 00:40:47

问题


The WHATWG document for HTML5 says that the rel attribute must contain values that are space-separated, and then it gives a table of allowed values.

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 link element does not include shortcut, but it does include icon. So I'm looking at the all-too-well-known tag

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

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


回答1:


From the same WHATWG document:

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.




回答2:


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

The shortcut link 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 shortcut in the W3C documentation, so I think it's better to leave it out. https://www.w3schools.com/tags/att_link_rel.asp




回答3:


Although it is still in its experimental stage (because HTML5 dev is ongoing), the w3.org HTML5 Markup Validator is 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.




回答4:


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

<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>


来源:https://stackoverflow.com/questions/13211206/html5-link-rel-shortcut-icon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!