Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do <link href=""> tags only go in the <head> tag?

Is it possible/good practice to use <link href""> to include stylesheets outside of the <head> tag, or do they only work / should they be only used in <head>?

like image 270
Ali Avatar asked Apr 29 '11 05:04

Ali


People also ask

Where do link tags go?

The HTML <link> tag is used for defining a link to an external document. It is placed in the <head> section of the document.

Which tag is always placed inside the head tag?

The following elements can go inside the <head> element: <title> (required in every HTML document) <style>

Does CSS link need to be in head?

Most browsers put it anywhere in the page, but just be aware that it only takes effect from that point onwards. Also, it's not valid HTML if you don't put it in the head element. Also, it's considered best practise to put it in the head element as it improves page render times. Save this answer.

Which tags should go in the head element?

The <head> tag in HTML is used to define the head portion of the document which contains information related to the document. The <head> tag contains other head elements such as <title>, <meta>, <link>, <style> <link> etc. In HTML 4.01 the <head> element was mandatory but in HTML5, the <head> element can be omitted.


1 Answers

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).

like image 160
Boris Zbarsky Avatar answered Sep 21 '22 00:09

Boris Zbarsky