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 CSS Foundations Selectors Type, Class, and ID Selectors

I am unable to get past this question I have tried many different code applications none work.

It is CSS Foundations challenge task 2 of 6

index.html
<!DOCTYPE html>
<html>
<head>
    <title>CSS Selectors</title>
    <link rel="stylesheet" href="cc1-main-styles.css" type="text/css" media="screen">
    <link rel="stylesheet" href="style.css" type="text/css" media="screen">
</head>
<body>
  <body class="main-body">
    <h1><em>Hello</em> World!</h1>
    <h1 class="main-h1>
    <div>
        <p>
            <em>Lorem ipsum dolor</em> sit amet, consectetur adipiscing elit. Nunc pulvinar consequat tortor, nec venenatis erat elementum scelerisque. Curabitur sit amet risus nisi. Aenean aliquet euismod augue at viverra. Ut varius arcu in lorem iaculis ullamcorper. Integer eu rutrum quam.
        </p>
    </div>
</body>
</html>
style.css
/* Complete the challenge by writing CSS below */
.main-body {
  background:lightblue;
}  

.main-h1 {
  color:darkblue
}    

3 Answers

Thank you TJ! It is best to just keep it simple by following the questions carefully.

TJ Egan
TJ Egan
14,420 Points

try writing it like this -

body {
background-color:lightblue;
}

h1 {
color: darkblue;
}

Css is very picky on syntax, and won't work unless it is perfect. Here you were missing a semicolon.

Also, if you are targeting the h1 of the div with a class of .main, you need to separate the two. The way you had it written was telling the computer to apply the darkblue color to a class called 'main-h1'.

TJ

I wasn't even using the .main and it passed. I guess it could have gone either way. That's the funny thing about CSS.

/* Complete the challenge by writing CSS below */
body {
  background-color: lightblue;
}

h1 {
  color: darkblue;
}

Cheers!

TJ Egan
TJ Egan
14,420 Points

Yeah I hadn't loaded up the challenge and was just looking at the code provided. What you've got is the correct way to do it based on the challenge, edited mine to show that!