Introduction
In this article, we learn what less.js is and how to implement it.
LESS stands for Leaner CSS. LESS is a pre-processor. LESS extends the CSS language. In LESS we can declare variables. LESS runs inside nodes. In other words, LESS is a CSS framework that extends our CSS, it adds more features like initializing variables, mixings, functions, and many other technologies that make CSS more maintainable.
Let's add an HTML page and name it home.htm. Then add a folder and name it style. In this folder, we will add a CSS file and name it StyleSheet.css.
In style.css
In Home.html
- .Div { float:left; font-family: Georgia; font-size : 16px; background-color : black; color: #FFF; width:1000px; height: 40px; padding-top:10px; padding-left:30px; }
- .DivOne { float:left; font-family: Georgia; font-size : 20px; background-color:black; color: #FFF; width:1000px; height: 40px; padding-top:10px; padding-left:30px; }
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head> <link href="style/StyleSheet.css" rel="stylesheet" type="text/css"></link></head>
- <body> <div class="Div"> Pramod </div>
- <div style="clear:both; height:10px; width:10px;"></div>
- <div class="DivOne"> Ravi </div>
- </body></html>

Suppose the client says to me, please replace the black with red in the background color. In this scenario, I need to manually change the color code in all the CSS classes. That is a painful task for me. LESS provides a facility for declaring a variable. In LESS variables are case sensitive. In stylesheet.css I will declare a variable called bgcolor and set the color name to Red.
- @bgcolor: red;
- <link href="style/StyleSheet.css" rel="stylesheet/less" type="text/css"></link>
Add a reference of less.js and see the output.
- <script src="Scripts/less-1.7.5-min.js"></script>


Pramod ThakurPosted Nov 4, 2014, 5:08 AM
thank you sir :)
Dinesh BeniwalPosted Nov 3, 2014, 10:21 PM
Good work pramod.