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 stringshortcut
is not a registered keyword. The stringshortcut
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 theicon
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 stringshortcut%20icon
is not a registered keyword. The stringshortcut%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/