-2

This question is similar to this Can CSS detect the number of children an element has?

But istead of styling children I need to style container: HTML:

<ul>
</ul>

CSS:

.selector:before {
    content: "Empty list";
    color: red;
}

For the case of empty elements I can use :empty pseudo-class, but what if i want special styles for elements with N children ?

Community
  • 1
  • 1
iVenGO
  • 384
  • 1
  • 4
  • 17
  • 1
    That question seems to be asking how to style the container as well, but the accept mark on the answer seems to imply otherwise. I've commented on that question but will leave this one open in the meantime. – BoltClock Mar 03 '13 at 18:28

1 Answers1

1

There is currently no way to select a parent via it's children using CSS.

David Nguyen
  • 8,368
  • 2
  • 33
  • 49
  • Lea Verou answer to this question: Not currently :( We only have :empty, which means no children at all (including text nodes), but nothing more fine grained at the moment… It’s coming in Selectors 4 though! – iVenGO Mar 06 '13 at 21:26
  • http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/#comment-818383868 – iVenGO Mar 06 '13 at 21:28