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

Rasmus Sindberg
Rasmus Sindberg
1,274 Points

CSS Selectors Task 7/10 *Solved*

I seem to be stuck on this one - task is:

Add the class "important" to the CSS rules and make that class color red. Then add that class to the last paragraph.

But I still get this error: Don't forget to add the important class to the last paragraph.

My css code is (wrongly i know):

h3 + p[class~="important"] {
    color: red;
}

I hope one of you clever guys can get me back on track here...

6 Answers

A class is defined like this in HTML: < p class = "important" >. And in CSS with a dot and then the name of the class given in HTML.

/***** HTML *****/

< p class= "important" > < /p >

/***** CSS *****/

.important {color: red;}

Hope this helps!

Rasmus Sindberg
Rasmus Sindberg
1,274 Points

Thanks for your suggestion Andrew - however I still can't seem to get it to work.

The HTML code presented by the challenge looks like this: </p>

<h3 class="important_headline">Hello World</h3>
<p>

So as i read the challenge ("Add the class "important" to the CSS rules and make that class color red. Then add that class to the last paragraph.") - I need to refer to h3 as it is the last paragraph.

That one has a class name of:

"important_headline"

So I thought that by adding ~ - it would accept this - however it seems not to be the case. Making any changes in the HTML code - only results in previous steps to fail - so that is a no-go.

I bet it is a matter of me over complicating this one - but I can't seem to crack this one...

@Rasmus

If this is task 7/10

You do not need to change anything to the h3, just add the class important to the p element.

and then define the style in CSS.

Rasmus Sindberg
Rasmus Sindberg
1,274 Points

Herein is my problem - can't seem to figure out how :)

Okay - back to the drawing board - I must be missing something..

Rasmus Sindberg
Rasmus Sindberg
1,274 Points

Ahhh - it is me that needs to get back to drink coffee! I was dead set on that I was only allowed to make changes in the style.css file of the code challenge.

Sometimes you just can't see the trees for the forest.

This was a two parter with changes to be made in both the style.css and the index.html

Idd

Don't stress it! They will explain it again more detailed in CSS Foundations second edition.