0

In the following structure

<dl>
    <dt>Text</dt>
        <dd>MoreText</dd>
    <dt>Text 2</dt>
        <dd>MoreText 2</dd>
</dl>

I want to gray out a text (dt) if the corresponding dd is set to display:none. I belive that there is a way to combine css selectors to achieve this, but can´t find a working solution.

Zsolt Szilagyi
  • 4,741
  • 4
  • 28
  • 44

3 Answers3

1

There is no such thing as a "previous sibling" selector. There is an "next sibling" selector, though.

See this question for reference.

Community
  • 1
  • 1
Elias
  • 1,532
  • 8
  • 19
0

There is no such thing. You must use JS/JQuery for manipulating classes. You must look on css rules like on XPath to an element, you can go only deeper, not on sides.

Beri
  • 11,470
  • 4
  • 35
  • 57
0

I think it's not possible in CSS as you want to do this based on a condition.

But you can use jQuery / JavaScript to achieve the same

  1. By checking the status of neighbour.
  2. Then getting parent of it.
  3. Then selecting desired element finally.
  4. Making changes to desired element.
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Pratik
  • 337
  • 2
  • 8