Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML How to Make a Website Beginning HTML and CSS Write a CSS Selector and Property

Why is <style> tag nested within the body above the <h1> tag?

<body>

<style>
h1 { color: red; } </style>

<h1>Nick Pettit</h1>

</body>

Why is the style tag nested in the body? Is it not suppose to be inline or within the <head> tag?

2 Answers

Its because it won't get that messy . I guess you can put style tag somewhere else too don't remember.

i guess you can . More likely you will put css in other file . Don't worry . Look how he does next steps and you will understand what he mean . Basicaly he's styling straight away int the same file for the purpose of the video on how it works i guess.

Jeremy Hayden
Jeremy Hayden
1,740 Points

Yes, you can put your style tags inline with your code. However, if you put all your style tags together in one spot, it is easier to read a complex page of code. Also it is easier to change the style of your whole page all at once. He is teaching you a basic principal that your css code can be all lumped together. Soon he will also teach you that your css code doesn't even have to be on the same page, but could be on an external file that is imported in. This makes complex pages way easier to manage.