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 How to Make a Website CSS: Cascading Style Sheets Use ID Selectors

background-color in css

When I start my main css, I attempt to change the background-color like the video but mine doesn't change. Everything is correct until that very first step in main css. Any ideas?

6 Answers

Ste Royle
Ste Royle
9,538 Points

Can you show the code you have so far?

Check you have a file called main.css inside your css folder

Check that your main.css is being linked correctly in your index.html file

<link rel="stylesheet" href="css/main.css">

Check you have the following in your main.css file

body {
  background-color: orange;
}

I definitely have main css in my css folder. here is my code for index.html if have linking it. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Heather Wish | Designer</title> <link rel="stylesheet" href="css/normalize.css"> <link rel="styleheet" href="css/main.css">

here is my main.css code

body { background-color: orange; } I checked again and redid and still not changing background. Since I put out this question I just continued on and now my logo wont center. Ive had no problems until these and double checked my typing and don't know whats up.

Adama Sy
Adama Sy
7,076 Points

depending of the computer i used sometimes you simply don't need css/, you just put main.css and it works. or try to do some work and save again, make sur to delete any duplicate of the same css. i had that probleme where i was thinkiing , the right one was open while i was opening the old one and getting angry at nothing

thanks :)

Ste Royle
Ste Royle
9,538 Points

Do you only have the code below in your .index.html file?

<!DOCTYPE html> Heather Wish | Designer

If so there is no body tag which is why the styling can't be applied. Try adding the below code to your index.html file to test the styling is being applied correctly:

<!DOCTYPE html>
<html>
<head>
    <title>Heather Wish | Designer</title>
    <link rel="stylesheet" href="css/main.css">
</head>
<body>
    <p>Page content</p>
</body>
</html>

got it to work. I don't really know how. I took a break from it and came back and started fresh from the beginning and everything worked and my portfolio, about and contact pages look just like they are supposed too.

I have the same problem, can you help me! Here is my code, I really dont see where the error is...

<!DOCTYPE_HTML> <HTML> <head> <meta charset="utf-8"> <title> MOTORES DEL JAPON </title>
<link rel="stylesheet" href="CSS/normalize.css"> <link rel="stylesheet" href="CCS/main.css"> </head> <body> <header> <h1>Motores del Japón</h1>
<h3>Panamá</h3> </header> <nav> <UL> <LI>NOSOTROS</LI> <LI>MARCAS</LI> <LI>CONTACTENOS</LI> </UL> </nav> </body> <footer> <p>© 2014 NathyBWeb.</p> </footer> </HTML>

Nathalie I don't even know what I did that corrected it. I took a break from it for a day, because I was so frustrated with it trying over and over. I watched the videos over and over following along with exactly what I did. I finally came back to it and asked my husband what I might be doing wrong. He went into settings and clicked so that my computer was refreshing my page every time I toggled back and forth. he said it was different from just refreshing my work. I reopened my workspace and the webpage I was working on had all the proper colors. I don't know if this will help but luckily for me it did.