Is <link> (not rel="stylesheet") allowed to be used in <body>?
The WHATWG HTML specification mentions, that the LINK
-element can either have a rel
-attribute:
<link rel="…" />
or an itemprop
-attribute
<link itemprop="…" />
but not both.
The rel
-version is restricted to the HEAD
-element, whereas the itemprop
-version may appear in both, the HEAD
and BODY
-elements.
http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-link-element
What is this WHATWG specification:
whatwg.org/specs/web-apps/current-work/multipage/introduction.html#is-this-html5?
There was a change to HTML5 spec recently that allows having links in the body
Link is allowed in BODY. I had same problem validating link tag in HTML5 and I solved it with this
<link rel="stylesheet" property="stylesheet" href="css/homepage.css">
Need to have both property
and rel
tag
UPDATE 2016 (thanks to yuyokk below): There was a change to HTML5 spec recently that allows having links in the body
I'd like to add to the answers above, in short
<body>
<link rel="stylesheet" property="stylesheet" href="pathto.css">
</body>
is making the valdation error go away. Even just adding property=""
(RDFa syntax or itemprop=""
(Microformat syntax) attribute is sufficient. As @Jukka K. Korpela and @sideshowbarker explain in their answers, the reason lies in the HTML5+RDFa 1.1 spec.
The solution above is basically a workaround to let validator ignore inline stylesheets as needed in critical path implementations. In future versions of validators it hopefully gets obsolete.
By the way, in HTML5 you neither need a type
attribute nor self-closing tag syntax.