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

help getting CSS file to link - what are the steps

I am doing the beginning CSS course. My work matches the download file but when I save and refresh in my browser the html is not corresponding to the CSS file & grids.

Have I missed some step here?

Alex Hedley
Alex Hedley
16,381 Points

Can you post the code or CodePen so we can have a look?

If you inspect the page can you get to your css file, is it linked to the page correctly?

Are some parts showing up correctly?

Which browser are you using? Is it the same in all browsers?

5 Answers

James Barnett
James Barnett
39,199 Points

Sounds like you are having file path issues. I recommend you check out tutorial on file paths

I am using Chrome but just tried in Safari and same thing.

I suspect it is not linked correctly. All of the html content is fine, just none of the formatting.

I am new to all of this, can you explain how I inspect the page to see if I can get to the CSS?

Rajanand Ilangovan
Rajanand Ilangovan
3,226 Points

You should link your css file in between the header section in your html file and make sure that you have included the correct path name to point the .css file. http://pastebin.com/9G32LFVY

I have also been having this same problem. I tried using ' href="css/style.css" ' as well as ' href="style.css" ' but for some reason neither of these work. I am using a MacBook Air with OS X Mountain Lion, Sublime Text 2 as my text editor and Safari as my browser.

Rajanand Ilangovan
Rajanand Ilangovan
3,226 Points

hi tommy, basically in "href" attribute you are giving the path to the respective file(in this case .css file). if you have placed the index.html and style.css file in the same folder you can use href="style.css" It will work just fine.

Hi Rajanand,

I tried this with my stylesheet in a separate folder "css/style.css", but it did not work. The I put the stylesheet in the same folder as index.html (both located in a folder called "adding-css" but this did not work either. The only way I got it to work was when I put all the files directly on my desktop. I do not understand what I am doing wrong. Do you think the text editor I am using could be effecting this?

Rajanand Ilangovan
Rajanand Ilangovan
3,226 Points

there is nothing woring with the text editor you are using. "css/style.css" css is folder name and style.css is the css file name. i think you had different file name for the css file.

Thanks Rajanand, I think that helped. I don't think I had the html file in the same holder.

Thanks all for your suggestions, much appreciated :)

I got it working now as well. Thanks for the help Rajanand.

Thanks James. This was very helpful.