Nesting CSS classes

Not possible with vanilla CSS. However you can use something like: Sass Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin. Or Less Rather than constructing long selector names … Read more

not:first-child selector

One of the versions you posted actually works for all modern browsers (where CSS selectors level 3 are supported): If you need to support legacy browsers, or if you are hindered by the :not selector’s limitation (it only accepts a simple selector as an argument) then you can use another technique: Define a rule that has greater scope than what you intend and then “revoke” it … Read more

Set parent style via child

Let’s say I have the following <ul>: Is it possible for me to change the style of the <li> via the active <span>? E.g.: I’ve been able to achieve this with jQuery, but it flickers on the screen for a split second (waiting for the DOM to load) and I want to avoid that.

Is there a CSS parent selector?

There is currently no way to select the parent of an element in CSS. If there was a way to do it, it would be in either of the current CSS selectors specs: Selectors Level 3 Spec CSS 2.1 Selectors Spec That said, the Selectors Level 4 Working Draft includes a :has() pseudo-class that will … Read more