What's the difference if I put css file inside <head> or <body>?

Viewed 106997

Normally css files are put inside <head></head>, what if I put it inside <body></body>, what difference will it make?

12 Answers

Two conflicting answers:

From MDN page on link tag:

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 a <link rel="stylesheet"> is permitted in the body. This isn't however best practice; it makes more sense to separate your <link> elements from your body content, putting them in your head.

From CSS The Definitive Guide (4th Edition/2017) page 10

To successfully load an external stylesheet, link must be placed inside the head element but may not be placed in any other element.

Related