html - <link rel ="shortcut icon"> 验证错误尽管有效

标签 html favicon w3c-validation

w3.org 验证器在以下行中给我一个错误:

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

这是它给出的完整错误:

Line 1, Column 727: Bad value shortcut icon for attribute rel on element link: The string shortcut is not a registered keyword. The string shortcut is not an absolute URL.

…f="/favicon.ico" type="image/x-icon" />

Syntax of link type valid for :

A whitespace-separated list of link types listed as allowed on in the HTML specification or listed as an allowed on on the Microformats wiki without duplicate keywords in the list.

You can register link types on the Microformats wiki yourself.

绝对 IRI 的语法:绝对 URL。

For example: http://example.org/hello, but not /hello. Spaces should be escaped as %20.

我不明白的是我在关注 HTML5 spec其中说:

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.

我看到它建议将 %20 作为空格,我试过了:

<link rel="shortcut%20icon" href="/favicon.ico" type="image/x-icon" />

但是当我使用这段代码时,我得到的错误几乎是一样的,除了它开始时:

Error Line 1, Column 729: Bad value shortcut%20icon for attribute rel on element link: The string shortcut%20icon is not a registered keyword. The string shortcut%20icon is not an absolute URL.

最佳答案

似乎是 W3C 验证器的问题。我所有的 HTML5 项目——它们上周都是有效的——抛出与今天提到的相同的错误。使用替代验证器(例如 Validator.nu (X)HTML5 Validator)一切正常。

关于html - <link rel ="shortcut icon"> 验证错误尽管有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22616104/

相关文章:

html - Slack 中网站的 Favicon 模糊,Slack 的目标图标大小是多少?

css - W3C CSS Validator 如何识别 css3 文档?

php - 如何根据 w3c 使用 str_replace 或其他一些 php 函数使 img 标签有效?

iphone - 浏览器大小 html css

html - 绝对垂直居中导致部分div在超过浏览器窗口垂直大小时消失?

html - bootstrap 4 中的 jumbotron 风格的渐变旋转木马

odoo - 如何在 Odoo/OpenERP 中设置网站图标?

ruby-on-rails - Ruby on Rails 应用程序中的 Favicon

html - 谷歌字体 URL 破坏 w3.org 上的 HTML5 验证

javascript - 拖动一个div选择整个文本