0

I'm looking for a way to apply styling to the parent element of another element, using LESS/CSS.

For example:

HTML:

<div>
    <span class="chosen">Hello World</span>
</div>

I need the CSS to apply styling to the element given the specific class of the child.

CSS:

div {
    height: 50px;
    background-color: 'blue'
}

Perhaps something like:

.chosen {
    div& {
        height: 50px;
        background-color: 'blue'
    }
}

Any direction greatly appreciated.

(Apologies for lack of fiddle, unsure how to include LESS)

Fergmux
  • 724
  • 7
  • 13
  • This is neither possible with CSS nor LESS (since LESS transpiles to CSS in the first place). See the duplicate. JSFiddle does not support LESS, but JS Bin does. – BoltClock Jul 04 '14 at 15:21
  • Thanks very much, sorry for the dup. – Fergmux Jul 04 '14 at 15:23
  • No worries. Duplicates aren't necessarily a bad thing so long as they're not straight-up direct copy posts. – BoltClock Jul 04 '14 at 15:24

0 Answers0