LESS (stylesheet language)
LESS (Leaner CSS) is a dynamic stylesheet language designed by Alexis Sellier. It is influenced by Sass and has influenced the newer “SCSS” syntax of Sass, which adapted its CSS-like block formatting syntax.
Variables
LESS allows variables to be defined. LESS variables are defined with an at sign(@). Variable assignment is done with a colon (:).
During translation, the values of the variables are inserted into the output CSS document.[4]
@color: #4D926F;
#header {
color: @color;
}
h2 {
color: @color;
}
The code above in LESS would compile to the following CSS code.
#header {
color: #4D926F;
}
h2 {
color: #4D926F;
}
Mixins
Mixins allow embedding all the properties of a class into another class by including the class name as one of its properties, thus behaving as a sort of constant or variable. They can also behave like functions, and take arguments. CSS does not support Mixins. Any repeated code must be repeated in each location. Mixins allow for more efficient and clean code repetitions, as well as easier alteration of code.[4]
.rounded-corners (@radius: 5px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
#header {
.rounded-corners;
}
#footer {
.rounded-corners(10px);
}
The above code in LESS would compile to the following CSS code:
#header {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#footer {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
LESS has a special type of ruleset called parametric mixins which can be mixed in like classes, but accepts parameters.

Leave a Reply
Want to join the discussion?Feel free to contribute!