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.

HTML How to Make a Website CSS: Cascading Style Sheets Use ID Selectors

Luke Ghislain
Luke Ghislain
3,477 Points

My background color would not change! Plz help...

Ok so this is my html linking code <link rel="stylesheet" type="text/css" href="normalize.css"> <link rel="stylesheet" type="text/css" href="main.css"> Here is my main.css code body { background-color: orange; }

All of my files are lowercase, my code seems to be right, and i definitely put my main.css in my css folder. I've even tried sample code from the internet and it's still not working!

This is my sample code.

html sample code link --> https://www.w3schools.com/Tags/tag_link.asp

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

css sample code link --> https://www.w3schools.com/css/css_background.asp

body { background-color: lightblue; }

Any help is appreciated!

7 Answers

Maxime Duhamel
Maxime Duhamel
7,169 Points

Your link tag seems to be fine. The problem might come from somewhere else. Just to be sure of one point is your html at the root of the directory or do you have also a folder where you put your html document(s)?

Maxime Duhamel
Maxime Duhamel
7,169 Points

Hi,

It might be because your href should point to the css folder. I think if you replace the href of your css link with href="css/main.css" it should fix your problem. If so same thing goes for the href of your normalize css.

I hope I got that right and it helps.

Max

Robert Bennett
Robert Bennett
11,927 Points

The deprecated type="text/css" meaning it is done away with...

Your answer = <link rel="stylesheet" type="text/css" href="normalize.css"> My answer = <link rel="stylesheet" href="css/normalize.css">

Your answer = <link rel="stylesheet" type="text/css" href="main.css"> My answer = <link rel="stylesheet" href="css/main.css">

This code will work same one I used! body { background-color: orange; }

Luke Ghislain
Luke Ghislain
3,477 Points

Ive tried everything and it's still not working. But when I inspect my code on chrome, it says that it failed to load the css code. But when I type in the code manually, it works! But why isn't my css code loading?

Maxime Duhamel
Maxime Duhamel
7,169 Points

Could you confirm that your css documents are in the same directory as your html? Otherwise it could be because the path you specified in your link is not pointing to anything.

If you have your css in a css folder, href should be href="css/main.css" and same goes for normalize.css Let me know if it was the problem you were having.

Max

Luke Ghislain
Luke Ghislain
3,477 Points

Yes, my main.css and my normalize.css are in a css folder. But what I don't get is I already had the css/main.css and the css/normalize.css in my code. This is my html linking code.
<link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/main.css">

Luke Ghislain
Luke Ghislain
3,477 Points

Thank you Max. When I moved the index.html from the img folder to the root of the directory, it worked!