I.T. Discussion Community!
-Collapse +Expand
Search Design Group:

-Collapse +Expand Design Store

Prestwood eMagazine

September Edition
Subscribe now! It's Free!
Enter your email:

   ► KBWebsite DesignCascading St...   Print This     

Design Cascading Style Sheets (CSS):
When LESS is more
Posted 8 years ago on 7/13/2010

If you're like me, you probably love CSS, but are also a little disappointed in a few things it lacks; like constants or variables.

LESS is a fairly new bit of genius that solves some of the shortcomings in Cascading Style Sheets.


A good example is what I'll call a wished-for "color catalog."  I often make one, but it's just several lines of commentedd-out reminders about the color values used throughout the rest of my CSS file.  I can copy-n-paste color values from my "catalog" into my CSS classes. It saves errors, but it's still inconvenient.

Wouldn't it be nice if we could specify color values just once, assigned to a named constant, then, instead of typing in those inscrutable hex values all over your css, you could simply use your constant name for the color?

LESS lets you do that - and more.

It doesn't offer constants, but its variables can certainly do the job. It also offers "mixins," operations, and nested rules. The .NET version also offers a few useful functions.

How such a thing could be done is probably obvious: You write a LESS file, very much like an ordinary CSS file, but using the syntactical constructs introduced by LESS. Then you run your file through the LESS processor and it emits a standard CSS file.

There is obviously one potential downside: It adds a build step to your projects (unless you're working in .NET).  If you don't mind that, you should certainly look into LESS. 

Here are the pertinent Links:

This is the original LESS project, and uses a Ruby Gem to process your LESS files.

This is the .NET incarnation of LESS.  It has provisions for automating the processing of LESS files.


Share a thought or comment...
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1242A1
Enter key:
News Contributed By Wes Peterson:

Wes Peterson is a Senior Programmer Analyst with Prestwood IT Solutions where he develops custom Windows software and custom websites using .Net and Delphi. When Wes is not coding for clients, he participates in this online community. Prior to his 10-year love-affair with Delphi, he worked with several other tools and databases. Currently he specializes in VS.Net using C# and VB.Net. To Wes, the .NET revolution is as exciting as the birth of Delphi.

Visit Profile

 KB Article #102180 Counter
Since 7/13/2010
   Contact Us!
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

1,973 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...

©1995-2018 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech