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

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!