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

CSS

Hi. I have questions about stylesheets. I notice that some websites have stylesheets that begin with "http://"?

I would guess that their stylesheet is online in there server? Is their a benefit to why web developers do this?

3 Answers

Using http:// is called an absolute root. That means that no matter where the page, your machine, my machine, their machine, it will use THAT style sheet.

Using a relative root, such as css/main.css, will use the css that is on your machine in the relative folder, css.

I hope that sorta makes sense. Neither is 'better', it just depends on what you are doing.

Hi Christopher,

Just to add to what Logan said.

When you upload your website to your hosting company to take your website online then your stylesheet along with all your pages and images etc are then on their server. Having a relative path to your css when your building your website on your computer still means the path will be relative once you upload it to your hosting providers server as all your files are still together in the same place.

I can't think of a good reason why anyone would want to use a absolute path for their css, for one thing the website loading times would be a lot slower. I do however see a reason for people to use absolute paths for things like images as sometimes for whatever reason you can't get a copy for yourself.

Gotcha. Thanks guys.