1

I was wondering if there is a CSS-only way of styling an element based on it's child?

In my present situation, i've got an ul with a lot of li's in it. None of them have a separate identifying class, but only one of them got an iFrame (youtube video) inside of it. That li item, I want to style.

The CSS would somewhat be like

ul li:child-is[iframe] {
    // styling
}

Is this possible?

Sander Schaeffer
  • 2,757
  • 7
  • 28
  • 58
  • 1
    With pure CSS it is not possible as on today because there is no parent selector. You may have to use JS/jQuery. – Harry Jul 25 '14 at 09:27

1 Answers1

3

Not today.

In the next occurrence of CSS, CSS4, you'll be able to precise the subject in a selector using an exclamation mark :

ul !li iframe { 
    // styling applies to the li element
}

but there's no pure CSS solution today.

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758