---
title: "LESS is More"
url: "/articles/less-is-more"
type: article
date: 2012-09-19
updated: 2014-05-15
---

# LESS is More

#  LESS is More 

 The New CSS Tool that Enables Easier CSS Organization and Editing

 By

 [  Sean Lange   ](/about/sean-lange) 

 September 19, 2012

  

If youâ&#128;&#153;ve been watching the web design community for the past year or two, youâ&#128;&#153;ve probably heard of LESS. Basically, itâ&#128;&#153;s an enhanced style of CSS that lets you build complex CSS faster and easier. Run that file through the LESS program, and with just a dose of 'wiz' and a dash of 'bang,' the result is a normal CSS document that youâ&#128;&#153;re already familiar with. Once you have the hang of it you will never go back. LESS is to CSS, what CSS is to HTMLâ&#128;¦ it's that good.

### A little about CSS

CSS stands for Cascading Style Sheets. Style sheets allow us to separate visual presentation instructions from the HTML markup itself. Thanks to this revolution we said goodbye to many, many lines of HTML markup that were placed directly into the DOM structure, and to table layoutsâ&#128;¦ nice!

CSS brought plenty of advantages. For example, before CSS presentation code wasâ&#128;¦

- Intertwined directly with the page elements and contentâ&#128;¦ messy.
- Repeated multiple times on the same pageâ&#128;¦ redundant.
- Implemented in different ways within the same document and siteâ&#128;¦ inconsistent.

### So who's the new kid on the block? 

It's LESS. How does it work? LESS allows you to write CSS using nesting, simple variables, and other things that normally arenâ&#128;&#153;t supported. That lets you organize your CSS rules in hierarchies, group things logically, and avoid repeating the same CSS over and over. Then, the LESS script turns the file into normal CSS files for the browser. I say 'LESS is more' because it lets you write less CSS code, while accomplishing more!

### I can be a better Drupal Themer

I'm a Drupal front end developer, and what was important to me is how this could improve my Drupal theming. When I decided to commit to using LESS, I was quickly able to see many benefits for my Drupal theming?

LESS improved my Drupal theming process/workflow by allowing me toâ&#128;¦

- create reusable css structures that speed up time writing css.
- create variables, so that if I change a color, I change the variable once, and don't need to 'find and replace' for several minutes.
- create reusable css that you can insert values intoâ&#128;¦ i.e. write your â&#128;&#156;rounded cornersâ&#128;&#157; CSS once, then reuse it with different sizes as needed.

Let me explain a little deeper why I think LESS is superior to writing CSS. Web browsers read CSS, so ultimately you have to end up with a .css file to render the page. Normally when writing .css we just make a long list of display rules, then try to keep them 'together,' 'in order,' and (hopefully) 'logical'.

**Example 1:**

  ```

#main-menu {â&#128;¦}
#main-menu img {â&#128;¦}
#main-menu ul.menu {â&#128;¦}
#main-menu ul.menu li {â&#128;¦}
#main-menu ul.menu a {â&#128;¦}
  
```

### [A thought... with another thought's hat on.](https://www.tvfanatic.com/quotes/its-a-a-thought-with-another-thoughts-hat-on/)

Let's look at a more extreme example to illustrate a point. If we were creating an address book entry, and were using something like CSS markup, we would write down someone's contact information like thisâ&#128;¦

**Example A:**

  ```

Jon Smith [â&#128;¦]
Jon Smith's address [â&#128;¦]
Jon Smith's phone (h) [â&#128;¦]
Jon Smith's phone (w) [â&#128;¦]
Jon Smith's email [â&#128;¦]
  
```

However; we would never do that! (At least, I don't think we would.) Instead, we want to use a simpler, more organized way to document this informationâ&#128;¦

**Example B:**  
`Jon Smith<br></br>  address:<br></br>  phone<br></br>    (h):<br></br>    (m):<br></br>  email:<br></br>  `

### From LESS to CSS

That nested hierarchy concept is the basis for writing LESS. I can enter something like the following, using LESS hierarchy, and it will automatically generate the same â&#128;&#156;flatâ&#128;&#157; CSS from Example 1.

**Example 2:**

  ```

#main-menu {
  img { }
  ul.menu { 
    li { }
    a { }     
  }
}
  
```

### LESS is more powerful

This is a pretty basic example and is more to demonstrate the mind-set that I use for LESS. If you need to write a dozen lines of CSS, LESS is probably not needed. If youâ&#128;&#153;re working on a CSS file that has hundreds of lines, with dozens of nested divs and selectors, then LESS is a powerful and empowering way to write that CSS code. When you combine the structure of LESS with things like variables, mixins, operations and functionsâ&#128;¦ writing CSS just got a whole lot more fun!

### A Bonus Example (variables)

Perhaps you are in a project that has a lot of rounded corners. You have to make small adjustments for each one of the elements, so you keep re-writing the radius properties each time. Stop doing thatâ&#128;¦ write LESS! Declare your variable as a class and use it over, and over, and over again.

**LESS Code:**

  ```

.round-my-corners(@radius: 10px) {
 -webkit-border-radius: @radius;
 -moz-border-radius: @radius;
 border-radius: @radius;
}
#normal_box {
 .round-my-corners;
}
#small_box {
 .round-my-corners(5px);
}
#large_box {
 .round-my-corners(20px);
}
  
```

**Generated CSS Results:**

  ```

#normal_box {
 -webkit-border-radius: 10px;
 -moz-border-radius: 10px;
 border-radius: 10px;
}
#small_box {
 -webkit-border-radius: 5px;
 -moz-border-radius: 5px;
 border-radius: 5px;
}
#large_box {
 -webkit-border-radius: 20px;
 -moz-border-radius: 20px;
 border-radius: 20px;
}
  
```

### I &lt;3 LESS

There is so much more to LESS. My goal with this post is to hopefully spark your interest. Perhaps engage you to take a chance on it if you have been considering it. If you are interested in more details there a few sites you would want to check out.

- The [official LESS site](https://lesscss.org/) has a lot of good examples and documentation
- The [LESS Mac app](https://codekitapp.com/index.html) is what I prefer
- The [LESS Code plugin](https://codekitapp.com/index.html) looks pretty interesting, though I haven't tried it yet
- The [LESS Windows version](http://wearekiss.com/simpless)

 Published in:

- [  UX &amp; Design   ](/topics/design-and-ux)

 

   You must have JavaScript enabled to use this form.

## Get in touch with us

### Tell us about your project. We'd love to hear from you!

 First Name  

 Last Name  

 Your email address  

 Your organization  

 How you heard about us  

 Tell us more 

     Leave this field blank