Is it possible/good practice to use to include stylesheets outside of the
tag, or do they only work / should the
The tag defines the relationship between a document and an external resource.
The tag is most used to link to style sheets.
Note: The link element must be embedded in the head section, and it can appear any number of times.
From: http://www.w3schools.com/tags/tag_link.asp
The LINK element
(<link>)
is used to add external information related to the HTML document in the header of your document in the HEAD element.
From: http://www.w3.org/QA/Tips/use-links
The <link>
tag does not define structure of a webpage, so it should stay out of the <body>
and <footer>
.
I can't think of any reason why you would ever want/need to put it anywhere other than the <head>
Yes, element is metadata element, whose permitted parent is head, or a element in head.
According to the HTML 4.01 spec, the <link>
tag must appear in the head section:
This element defines a link. Unlike A, it may only appear in the HEAD section of a document, although it may appear any number of times. Although LINK has no content, it conveys relationship information that may be rendered by user agents in a variety of ways (e.g., a tool-bar with a drop-down menu of links).
Source W3C: http://www.w3.org/TR/html401/struct/links.html#edef-LINK
It's possible to do it.
It's not recommended to do it, because whatever content comes before the <link>
will start rendering and then when the stylesheet is loaded will be rerendered with the new styles. That means that the pageload will be slower (because the browser has to redo all that work) and uglier (because there will be this flash of content with one style that's then restyled to look different).
They are invalid outside of head
, though no browser I know of won't apply the styles if not a child of head
.