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


Trouble Linking Stylesheet

Can't seem to get external CSS stylesheet to link with HTML. No style changes are appearing in my browser. Both index.html and style.css are saved to the folder, "Treehouse" on my desktop.

<link rel="stylesheet" href="treehouse/style.css">

  • { margin: 0; padding: 0; color: red; }

2 Answers

Justin Iezzi
Justin Iezzi
18,199 Points

Hi Lindsay, the issue you are having is based on the location of your files. Your HTML file is basically the root point of which you base your paths off of. For example, if your HTML and CSS are both in a folder called "Treehouse", your HTML file already knows its in Treehouse, so that's its root. You are telling your HTML file to find style.css in a further treehouse folder inside your current treehouse folder.

In order to get this to work, you'll need to remove the treehouse/ part inside href="treehouse/style.css".

As a suggestion, it is good practice to organize your files with folders by type. All of your CSS files could go into a folder called css, all of your image files could go into a folder called images, and so on. If you did this, only then would you use something like href="css/style.css"> as the files would be in a further folder from your index HTML file. This would make your project files much cleaner and easier to understand.

Hi Justin, thank you. Worked perfectly. I appreciate the tips about best practice, as well. I'll start separating out my files by folder-type.

Thanks again!