Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

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

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!