-2

Possible Duplicate:
Is there a CSS parent selector?

Is there some kind of .this selector in css?

Or maybe parent selector?

Thanks

Community
  • 1
  • 1

3 Answers3

1

There is no parent selector existing in CSS.

The only thing existing that comes somehow near to that is this:

a < img { border: none; }

But this is not a parent selector. This would select a tags but only if they contained an img tag.

Sven Bieder
  • 5,081
  • 2
  • 18
  • 27
0

There is no parent selector in CSS. See Is there a CSS parent selector?.

Why would you need a this selector? It would be redundant, because it implies you have already selected the target element.

Community
  • 1
  • 1
calebds
  • 23,502
  • 7
  • 39
  • 73
0

well, I don't know if you mean this, but you can always start from the "parent" element, and then go deeper... e.g.

div#main_div div#sub_div1 div#sub_div2 span a {
    /* your style here */
}

your style will then apply to the a-element. However, only if you have this order (sub_div2 has to be in sub_div1, which has to be in main_div) in your html code as well...

Chris
  • 3,486
  • 6
  • 31
  • 53