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

General Discussion

external link to CSS file, how does it work?

Hi everyone, this is my very first topic on here although I am no stranger when it comes to online forums. I can't seem to find a section for newbies on here so please don't get annoyed with me if this is not the right place to post!

I'm learning CSS atm.

To link CSS externally, you will need to use this:

<head>

<link rel="stylesheet" type="text/css" href="mystyle.css"> </head>

so my question is, why does it have to be in the "head" section? Can't I just use them wherever I need them? e.g. in the body section or title section.

also I don't understand type="text/css" whats that for? Just trying to understand the syntax of it thats all. Maybe I'm worried too much.

Thanks!

1 Answer

James Barnett
James Barnett
39,199 Points

> why does it have to be in the "head" section

Because that's where web browsers know to look for a CSS file.

> I don't understand type="text/css" whats that for

That tells a web browser that the stylesheet is CSS and not some other kind of stylesheet. However as of HTML5 web browsers now assume any stylesheet is CSS unless they are told differently.