Less (style sheet language)

Short description: Dynamic stylesheet language

Less

Designed by| Alexis Sellier
Developer| Alexis Sellier, Dmitry Fadeyev
First appeared| Error: first parameter is missing. ()
Typing discipline| Dynamic
Implementation language| JavaScript
OS| Cross-platform
License| Apache License 2.0
Filename extensions| .less
Website| lesscss.org
Influenced by
CSS, Sass
Influenced
Sass, Less Framework, Bootstrap (v3)

Less (Leaner Style Sheets; sometimes stylized as LESS) is a dynamic preprocessor style sheet language that can be compiled into Cascading Style Sheets (CSS) and run on the client side or server side.[1] Designed by Alexis Sellier, Less is influenced by Sass and has influenced the newer "SCSS" syntax of Sass, which adapted its CSS-like block formatting syntax.[2] Less is an open source project. Its first version was written in Ruby; however, in the later versions, use of Ruby has been deprecated and replaced by JavaScript. The indented syntax of Less is a nested metalanguage, as valid CSS is valid Less code with the same semantics. Less provides the following mechanisms: variables, nesting, mixins, operators and functions; the main difference between Less and other CSS precompilers is that Less allows real-time compilation via less.js by the browser.[1][3]

## Contents

* 1 Features
* 1.1 Variables
* 1.2 Mixins
* 1.3 Functions and operations
* 2 Comparison
* 2.1 Sass
* 3 Use on sites
* 4 Less software
* 5 See also
* 6 References
* 7 External links

## Features

### Variables

Less allows variables to be defined. Variables in Less 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.[1]

@pale-green-color: #4D926F;

#header {
color: @pale-green-color;

h2 {
color: @pale-green-color;

The code above in Less would compile to the following CSS code.

#header {
color: #4D926F;

h2 {
color: #4D926F;

### Mixins

Mixins allows embedding all the properties of a class into another class by including the class name as one of its property, 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 allows for more efficient and clean code repetitions, as well as easier alteration of code.[1]

.rounded-corners (@radius: 5px 10px 8px 2px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;

#header {
.rounded-corners;

#footer {
.rounded-corners(10px 25px 35px 0px);

The above code in Less would compile to the following CSS code:

#header {
-webkit-border-radius: 5px 10px 8px 2px;
-moz-border-radius: 5px 10px 8px 2px;
border-radius: 5px 10px 8px 2px;

#footer {
-webkit-border-radius: 10px 25px 35px 0px;
-moz-border-radius: 10px 25px 35px 0px;
border-radius: 10px 25px 35px 0px;

Less has a special type of ruleset called parametric mixins which can be mixed in like classes, but accepts parameters.

#header {
h1 {
font-size: 26px;
font-weight: bold;

p {
font-size: 16px;
a {
text-decoration: none;
color: red;
&:hover {
border-width: 1px;
color: #fff;

The above code in Less would compile to the following CSS code:

#header h1 {
font-size: 26px;
font-weight: bold;

#header p {
font-size: 16px;

#header p a {
text-decoration: none;
color: red;

#header p a:hover {
border-width: 1px;
color: #fff;

### Functions and operations

Less allows operations and functions. Operations allow addition, subtraction, division and multiplication of property values and colors, which can be used to create complex relationships between properties. Functions map one-to-one with JavaScript code, allowing manipulation of values.

@the-border: 1px;
@base-color: #111;
@red:        #842210;

#header {
color: @base-color * 3;
border-left: @the-border;
border-right: @the-border * 3;

#footer {
color: @base-color + #003300;
border-color: desaturate(@red, 10%);

The above code in Less would compile to the following CSS code:

#header {
color: #333;
border-left: 1px;
border-right: 3px;

#footer {
color: #114411;
border-color: #7d2717;

## Comparison

### Sass

Both Sass and Less are CSS preprocessors, which allow writing clean CSS in a programming construct instead of static rules.[4]

Less is inspired by Sass.[5][2] Sass was designed to both simplify and extend CSS, so things like curly braces were removed from the syntax. Less was designed to be as close to CSS as possible, and as a result existing CSS can be used as valid Less code.[6]

The newer versions of Sass also introduced a CSS-like syntax called SCSS (Sassy CSS).

## Use on sites

Less can be applied to sites in a number of ways. One option is to include the less.js JavaScript file to convert the code on-the-fly. The browser then renders the output CSS. Another option is to render the Less code into pure CSS and upload the CSS to a site. With this option no .less files are uploaded and the site does not need the less.js JavaScript converter.

## Less software

Name | Description | Software License | Platform | Functionality

|
|
|
|

WinLess - Windows GUI for less.js | GUI Less Compiler | Apache 2.0[7] | Windows | Compiler
Crunch | Less editor and compiler (requires Adobe AIR) | GPL[8] | Windows, Mac OS X | Compiler
Editor
less.js-windows | Simple command-line utility for Windows that will compile *.less files to CSS using less.js. | MIT License[9] | Windows | Compiler
less.app | Less Compiler | Proprietary | Mac OS X | Compiler
CodeKit | Less Compiler | Proprietary | Mac OS X | Compiler
LessEngine | Less Compiler | Free | OpenCart Plugin | Compiler
SimpLESS | Less Compiler | free but no explicit license[10] | Windows
Mac OS X
Linux | Compiler
Chirpy | Less Compiler | Ms-PL[11] | Visual Studio Plugin | Compiler
Mindscape Web Workbench | Syntax highlighting and IntelliSense for Less and Sass | Proprietary | Visual Studio Plugin | Compiler
Syntax Highlighting
Eclipse Plugin for Less | Eclipse Plugin | EPL 1.0[12] | Eclipse Plugin | Syntax highlighting
Content assist
Compiler
mod_less | Apache2 module to compile Less on the fly | Open Source | Linux | Compiler
grunt-contrib-less | Node.js Grunt task to convert Less to CSS | MIT[13] | Node.js | Compiler
Web Essentials | Visual Studio extension with support for Less and Sass | Apache 2.0 [14] | Windows | Syntax highlighting, Content assist, Compiler
clessc | Pure C++ compiler | MIT[15] | at least Windows, Linux, MacOS | Compiler
Less WebCompiler | Web-based compiler | MIT[16] | at least Windows, Linux, MacOS | Compiler, Syntax highlighting, Minifier

## See also

* Sass (stylesheet language)
* Stylus (stylesheet language)

## References

1. ↑ 1.0 1.1 1.2 1.3 The Core Less Team. "Getting started | Less.js". http://lesscss.org/.
2. ↑ 2.0 2.1 Weizenbaum, Nathan (2009-06-17). "Sass and Less : Nex3". http://nex-3.com/posts/83-sass-and-less.
3. ↑ Meng, Jiew (2010-12-14). "css - Is there a SASS.js? Something like LESS.js?". in Mortensen, Peter. Stack Overflow. https://stackoverflow.com/questions/4436643/is-there-a-sass-js-something-like-less-js.
4. ↑ Atwood, Jeff (2010-04-30). "What's Wrong With CSS". https://blog.codinghorror.com/whats-wrong-with-css/.
5. ↑ The Core Less Team. "About | Less.js". http://lesscss.org/about/.
6. ↑ Eppstein, Chris (2010-11-10). "sass_and_less_compared.markdown". https://gist.github.com/674726.
7. ↑ Lagendijk, Mark (2013-01-29). "License Information · Issue #55 · marklagendijk/WinLess". https://github.com/marklagendijk/WinLess/issues/55#issuecomment-12863789.
8. ↑ Dean, Matthew (2011-12-02). "Crunch/LICENSE.txt at master · matthew-dean/Crunch". https://github.com/matthew-dean/Crunch/blob/master/LICENSE.txt.
9. ↑ Smart, Duncan (2013-07-25). "less.js-windows/LICENSE at master · duncansmart/less.js-windows". https://github.com/duncansmart/less.js-windows/blob/master/LICENSE.
10. ↑ Engel, Christian (2012-07-29). "SimpLESS/LICENSE.txt at master · Paratron/SimpLESS". https://github.com/Paratron/SimpLESS/blob/master/LICENSE.txt.
11. ↑ Evan Nagle. "Chirpy - VS Add In For Handling Js, Css, DotLess, and T4 Files - CodePlex Archive". https://archive.codeplex.com/?p=chirpy.
12. ↑ Vincent Simonet. "Eclipse plugin for LESS". http://www.normalesup.org/~simonet/soft/ow/eclipse-less.html.
13. ↑ Kellen, Tyler (2012-09-04). "grunt-contrib-less/LICENSE-MIT at master · gruntjs/grunt-contrib-less". https://github.com/gruntjs/grunt-contrib-less/blob/master/LICENSE-MIT.
14. ↑ Kristensen, Mads (2014-06-18). "WebEssentials2013/LICENSE.txt at master · madskristensen/WebEssentials2013". https://github.com/madskristensen/WebEssentials2013/blob/master/LICENSE.txt.
15. ↑ Bram van der Kroef (2017-07-11). "clessc/LICENSE at master · BramvdKroef/clessc". https://github.com/BramvdKroef/clessc/blob/master/LICENSE.
16. ↑ SamBrishes (2018-12-15). "snout.less/LICENSE.md at master · pytesNET/snout.less". https://github.com/pytesNET/snout.less/blob/master/LICENSE.md.

## External links

* v
* t
* e

Style sheet languages

Modes|

* Desktop publishing
* Web development
* User interfaces

Standard|

* Cascading (CSS)
* DSSSL
* Extensible (XSL)

Preprocessor|

* JavaScript (JSSS)
* FOSI
* Qt
* Sass
* Less
* Stylus
* SMIL Timesheets
* PostCSS

* List
* Comparison

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Less (style sheet language). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Less_(style_sheet_language)&oldid=2624213"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template