How to use if statements in LESS

There is a way to use guards for individual (or multiple) attributes. @debug: true; header { /* guard for attribute */ & when (@debug = true) { background-color: yellow; } /* guard for nested class */ #title when (@debug = true) { background-color: orange; } } /* guard for class */ article when (@debug = … Read more

Does LESS have an “extend” feature?

Yes, Less.js introduced extend in v1.4.0. :extend() Rather than implementing the at-rule (@extend) syntax used by SASS and Stylus, LESS implemented the pseudo-class syntax, which gives LESS’s implementation the flexibility to be applied either directly to a selector itself, or inside a statement. So both of these will work: .sidenav:extend(.nav) {…} or .sidenav { &:extend(.nav); … Read more

LESS CSS nesting classes

The & character has the function of a this keyword, actually (a thing I did not know at the moment of writing the answer). It is possible to write: .class1 { &.class2 {} } and the CSS that will be generated will look like this: .class1.class2 {} For the record, @grobitto was the first to … Read more