Shawn Shawn - 3 months ago 7
CSS Question

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

Normally css files are put inside

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

Answer

Just to add on to what jdelStrother has mentioned about w3 specs and ARTstudio about browser rendering.

It is recommended because when you have the CSS declared before <body> starts, your styles has actually loaded already. So very quickly users see something appear on their screen (e.g. background colors). If not, users see blank screen for some time before the CSS reaches the user.

Also, if you leave the the styles somewhere in the <body>, the browser has to re-render the page (new and old when loading) when the styles declared has been parsed.