Skip to content

Prevent CSS class or rule-set from rendering when using LESS mixins

by mstrid on June 17th, 2014

Sometimes, when working with LESS, I write CSS rule-sets that are only used as LESS mixins and in this case it is of course unnecessary to render the rule-set on its own in the CSS. The other day I stumbled upon the fact that if you make the CSS rule-set a LESS parametric mixin with no arguments the mixin is not outputed. So instead of writing

.a {
color: red;
}

.b {
.a;
}

Write

.a() { 
color: red;
} 

.b { 
.a; 
}

Comments are closed.