The !important
statement in CSS can be used to get some style rules always applied no matter where that rules appears in the CSS code. In Less, the !important
statement can be applied with mixins and variable declarations too.
You can write the Less code for this recipe with your favorite editor. After that, you can use the command-line lessc
compiler, as described in the Installing the lessc compiler with npm recipe in Chapter 1, Getting to Grips with the Basics of Less, to compile the Less code. Finally, you can inspect the compiled CSS code to see where the !important
statements appear. To see the real effect of the !important
statements, you should compile the Less code client side, with the client-side compiler less.js
, as described in the Downloading, installing, and integrating less.js recipe in Chapter 1, Getting to Grips with the Basics of Less, and watch the effect in your web browser.