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 Selectors Advanced Selectors :root and :target

YOUSSEF D
PLUS
YOUSSEF D
Courses Plus Student 3,778 Points

:target for hidden and show div

Why I cannot setting

col-c:target {

display: normal;

}

after

col-c {

display: none;

}

?

2 Answers

Christina Giannouli
Christina Giannouli
18,202 Points

I am not sure I have understood what exactly it is that you're asking but if I got this right you need to specify the element's id (with a pound sign) before the pseudo selector. In your case, you have to do this:

#col-c:target { display: none; }

Also, as far as I know the "normal" is not a valid value for the "display" css property. You can check here (MDN) for the full list of property's values.

YOUSSEF D
YOUSSEF D
Courses Plus Student 3,778 Points

I mean how to show and hide the div by that .

You can do this:

#col-c {
  display: none;
}

#col-c:target {
  display: initial;
}

And then Column C will only be shown when targeted. Since :target has greater specificity, the ordering does not seem to matter.