SlideShare a Scribd company logo
LESS CSS
By
Man Math
Support Developer
097 847 0 847
man@web-essentials.asia
Agenda
• What is LESS ?
• LESS features
• LESS Advantages
• How to use LESS ?
• References
• Demo
225-May-2013
What is LESS ?
• Dynamic Style sheet language designed
by Alexis Sellier
• The CSS pre-processors
• Leaner/Meaner CSS
• Valid CSS is valid LESS
25-May-2013 3
LESS Features
• Less variable defined with at sign (@)
Less CSS
25-May-2013 5
Variable
Operations
• Less allows addition, subtraction, division
and multiplication of property values and
colors
Less CSS
25-May-2013 6
Function (build-in)
• Functions map one-to-one with JavaScript
code, allowing manipulation of values. It
could be Math functions, color function,
…
Less CSS
25-May-2013 7
Color
Functions
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.
25-May-2013 9
Less CSS
25-May-2013 10
Nested
Less CSS
25-May-2013 11
Guard Expression (if
statement)
Less
25-May-2013 12
Guard Expression (if
statement)
CSS
25-May-2013 13
Variable scope
• The scope is
inside the curly
bracket ({ }),
otherwise you
have to declare
as global
25-May-2013 14
Error
LESS Advantages
• Increase readability and organization of
CSS using:
Imports
Nested rules
Comments
/* comment here */
// quick comment
25-May-2013 15
LESS Advantages
• Decrease how much CSS you have to
write using:
Variable
Function and Operations
Mixins
Expression statement
Namespace
25-May-2013 16
LESS is more
while
CSS is always sucks
How to use LESS ?
Client side
• Include your less file (*.less) in <head> tag
• Download less.js from http://lesscss.org
• Include less.js after your less file <head>
Make sure you include style sheets before the script
25-May-2013 19
Server side
• Installation (Unix/Linux OS)
$ npm install –g less
• Command line
Compile less as plain CSS
$ lessc style.less > style.css
This command will output the simple plain CSS
25-May-2013 20
Server side
• You might want minified CSS output
Simple minified CSS
$ lessc –x style.less > style.css
Most minified CSS
$ lessc –yui-compress style.less > style.css
For more command option you can run
$ lessc or
$ lessc --help
25-May-2013 21
Less compiler on Windows or
Mac
• Cygwin (http://cygwin.com)
• SimpLESS (http://wearekiss.com/simpless)
• Koala (http://koala-app.com)
• WinLESS (http://winless.org)
• …
25-May-2013 22
References
• http://lesscss.org
• http://css-tricks.com/sass-vs-less
• http://dotlesscss.org
• http://leafo.net/lessphp
• https://github.com/cloudhead/less
• http://en.wikipedia.org/wiki/LESS_(styles
heet_language)
25-May-2013 23
Demo
Thanks You!

More Related Content

LESS CSS