This forum is now read-only. Please use our new forums at discuss.codecademy.com.

CSS: An Overview Forum

View Course » View Exercise

80 points
52a794aa631fe9f207000295_545308218
Submitted by
Lisa Valera
over 3 years ago

Why is CSS in the head?

Could I get a better explanation for why we put CSS in the head and not the body, when it affects the body? This just doesn't seem logical to me.


3 votes

permalink

CSS is linked in the head tags so it can style as it goes down the page. If you put it, for example, in the footer, the browser will have to wait until it gets to the bottom of the page to style everything. In other words, it will have to render the page twice, making it significantly slower. If you do not have a lot of CSS, however, the effect will be likely unnoticeable.

596 points
52a2560c8c1ccc5ac400064c_914770763
Submitted by
Tyler
over 3 years ago

1 Comment

52a794aa631fe9f207000295_545308218 Lisa Valera over 3 years ago

thanks, tyler!!


0 votes

permalink

Yes. I have the same question...

104 points
5f06d3527988d57290b864a41d992941?s=140&d=retro
Submitted by
webeasties
over 3 years ago

1 Comment

5f619a4745f1a45563f7774e76f72435?s=140&d=retro Seth over 3 years ago

I tested putting the inside of in Lesson 5/26 and it worked just fine. Maybe it's just a matter of preference?


0 votes

permalink

it's in the head, because the creators of this markup language decided to divide an HTML page in 2 sections: 1)HEAD (here goes style, title, link, script, meta information) and 2)BODY your text, tags, images, paragraphs and etc.

365 points
543fc82f631fe988640020d7_382532424
Submitted by
Tobias Páez
over 2 years ago