Search code examples
csslesscss-specificity

More precedence/specificity to CSS class in LESS


I've a LESS code like:

.block__element {
  background: red;
  &--modifier {
    background: yellow;
  }
}

I want more specificity to .block__element--modifier such as:

.block__element.block__element--modifier {
  background: yellow:
}

So that it can overrides some other styles. I can achieve it by:

.block__element {
  background: red;
  &--modifier.block__element {
    background: yellow;
  }
}

I want to know is there any easy way?


Solution

  • .block__element {
        background: red;
        &&--modifier {
            background: yellow;
        }
    }
    

    link