Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is <link> (not rel="stylesheet") allowed to be used in <body>?

The new schema.org by Google, Yahoo and MS recommends usage of the <link> attribute to display the status of products in an online shop:

<div itemscope itemtype="http://schema.org/Offer">   <span itemprop="name">Blend-O-Matic</span>   <span itemprop="price">$19.95</span>   <link itemprop="availability" href="http://schema.org/InStock"/>Available today! </div> 

Yet, according to w3schools.org <link> is only allowed in head sections:

Note: This element goes only in the head section, but it can appear any number of times.

I am not used to W3C style, so I was not able to understand the exact definition by W3C. Can anybody help me: Is it really allowed to use <link> within the body (in HTML5, as schema.org uses HTML5 tags) or do Google, Yahoo and MS break the standard?

like image 564
aufziehvogel Avatar asked Jun 04 '11 10:06

aufziehvogel


People also ask

Can I use link tag in body?

A <link> element can occur either in the <head> or <body> element, depending on whether it has a link type that is body-ok. For example, the stylesheet link type is body-ok, and therefore <link rel="stylesheet"> is permitted in the body.

Can you put CSS link in body?

No, it is not okay to put a link element in the body tag.

Is rel StyleSheet required?

The rel is required because it specifies the relationship between the current document and the linked document.

What does link rel StyleSheet mean?

The REL attribute is used to define the relationship between the linked file and the HTML document. REL=StyleSheet specifies a persistent or preferred style while REL="Alternate StyleSheet" defines an alternate style. A persistent style is one that is always applied when style sheets are enabled.


1 Answers

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

like image 78
Mladen Janjetovic Avatar answered Sep 21 '22 07:09

Mladen Janjetovic