A CSS preprocessor is a scripting language that extends CSS and gets compiled into native CSS syntax that your browser expects to see and render. A CSS preprocessor lets you use nesting, mixings, functions, partials, etc which is not currently supporting my native CSS. Adding CSS preprocessor to your project gives you CSS superpower where you can use a single piece of code multiple and also you can target multiple browsers.
There are several CSS preprocessors exists nowadays, out of these Sass, Less, Stylus, and PostCSS are very popular among dev community but also there few less popular CSS preprocessor is there which has large numbers of users. Let’s talk about these –
Highly Popular CSS preprocessor
1. SASS
Syntactically Awesome Style Sheet which commonly known as SASS which is the oldest CSS preprocessor that was released in 2006. SASS is the most stable, mature, fully-fledged, and powerful professional class CSS extension language in the world. Creators of SASS are Hampton Catlin and Natalie Weizenbaum they were influenced by the Haml templating language which adds dynamic features to HTML. SASS needs Ruby to work and offers two different syntax types depending on the user’s preference. It is easy to adopt its principles as it is the most common language choice as it doesn’t differ syntactically from plain CSS. There is also a C/C++ port of the Sass precompiler known as LibSass which gives a high boost to the utilization of SASS.
Released in | 2006 |
Available on | Dart, SassC, Crystal, Go, Java, JavaScript, Lua, .NET, Node, Perl, PHP, Python, Ruby, Scala |
Extension | .sass , .scss |
Pros
- There is no trouble in picking it up for new collaborators because it is CSS friendly.
- LibSass is easy to build, fast, and portable.
- There is the lowest barrier to entry, you can make use of powerful features by simply learning a couple of new symbols.
- SASS compatible with all versions of CSS.
Cons
- As with any structure, there’s a risk you’ll become reliant on this approach, and not fully grab the underlying language.
Exmaple Syntax:
// _base.sass
$font-stack: Helvetica, sans-serif
$primary-color: #333
body
font: 100% $font-stack
color: $primary-color
2. LESS
Learner style sheet which commonly known as LESS is another most popular CSS preprocessor and strong also. In its feature set its style looks similar to SASS. After used in the source twitter bootstrap it popularity got a big boost. It is a dynamic stylesheet language written in javascript that compiles to CSS and runs on the server-side as well as the client-side.
Released in | 2009 |
Available on | Node and Javascript |
Extension | .less |
Pros
- Easy to find a previous example or any kind of help to use LESS as it is backward compitable.
- Its set up is easy as it is written in Javascript.
- Its has a very active community and detailed documentation.
Cons
- It doesn’t have wider use so it is suggested to spent more time learning SASS.
- Uses @ to reveal variables, but in CSS, @ already has meaning (it’s used to declare @keyframes and @media queries) which may confuse.
Example Syntax:
@width: 10px;
@height: @width + 10px;
#header {
width: @width;
height: @height;
}
3. Stylus
The stylus is a dynamic CSS preprocessor language that is designed by TJ Holowaychuk who is also the creator of luna language. The initial design of stylus was influenced by LESS and SASS but it provides a wider range of features and it gives users more freedom. The stylus is used by Mozilla to redesign its developer network. It makes coding more presentable and readable as it allows colons, semicolons, and omit braces.
Released in | 2010 |
Available on | Node |
Extension | .styl |
Pros
- Its built-in function is extremely powerful.
- It can do more ‘heavy lifting’ and more computing in your styles.
Cons
- Too leniency can lead to confusion.
- It doesn’t appear to be a highly active department.
Example Syntax:
border-radius()
-webkit-border-radius: arguments
-moz-border-radius: arguments
border-radius: arguments
body
font: 12px Helvetica, Arial, sans-serif
a.button
border-radius(5px)
4. PostCSS
When it comes to preprocessing PostCSS is the best alternative of SASS, LESS, and stylus. It grasps a modular plugin system which allows user to customize their compilation and feature set as much as they want. In this, you can simply add plugins whichever you want to use.
Released in | 2013 |
Available on | Javascript |
Extension | .css |
Pros
- It has good speed but if you use few plugins.
- No need to learn a new syntax.
- It let you use modern CSS without worrying about compatibility as compiles CSS which most browsers understand and determine required polyfills according to your target browser and environment.
Cons
- It generally requires more efforts and maintenance to installing preprocessor
A Compression of Interest of Stylesheet Technology on google
5. CSS Crush
It ranges way behind SASS AND LESS in terms of popularity but it shouldn’t be an excuse to misjudge its ability as it comes with modern features that enable a modern and uncluttered CSS workflow.
It is written in PHP which can be used neatly in conjunction with popular PHP content management systems such as Drupal or WordPress, But it can also be used in javascript by JS API.
Pros
- Its has an open-source which helps in fixing your own issues theoretically.
- It has useful plugins available, like HTML canvas and working with aria roles.
Cons
- Lacks in popularity.
- Need more maintenance.
Syntax Example:
/* Defining variables */
@set {
dark: #333;
light: #F4F2E2;
smaller-screen: screen and (max-width: 800px);
}
/* Using variables */
@media $(smaller-screen) {
ul, p {
color: $(dark);
/* Using a fallback value with an undefined variable */
background-color: $(accent-color, #ff0);
}
}
6. PLEEEASE
Pleeease is another CSS preprocessor it works slightly different from other CSS preprocessors it tries to tackle some practical issues its main goal is to perform all treatments that a pre-processor shouldn’t have to do rather than focusing purely on layouts and syntax.
Pros
- You can see the original code as it generates source map
- It now adds variable, prefixes, pseudo-elements and unit support
Cons
- It is not very well known preprocessor so you may find it difficult to find a resource
- The feature that allows for the addition to other preprocessors is completely experimental at this stage
7. Garden
This one is completely different from others as it pretty much does away with the conventional language of CSS. It makes use of maps to represent declarations and vectors to represent rules that are invented for stylesheet authors who were interested in what’s possible when you trade a preprocessor for a programming language.
Pros
- It accesses to the key features of a powerful programming language in Clojure.
- Garden Gnome plugin allows you to pipe style modify directly to the browser without reloading.
Cons
- It is more difficult to read as it has a different syntax to regular CSS or any other preprocessor.
8. Myth CSS
Myth is a Nodejs based CSS preprocessor that lets you use future CSS without worrying about browser support and W3C follow suit. it is like CSS polyfill.
Pros
- It adds vendor prefixes, so you don’t have to worry about cross-browser support.
- No need to learn a new stylesheet language, you can just write it in native CSS.
Cons
- It is a new and less popular css preprocessor language.
Conclusion
Here are the best 8 CSS preprocessors you can use according to your need after considering their pros and cons. In my suggestion, you should go for that CSS preprocessor which will give you more benefits, more features according to your work.
Very useful blog.
Howdy! I could have sworn I’ve been to this blog before but
after reading through some of the post I realized it’s new to
me. Anyhow, I’m definitely glad I found it and I’ll be bookmarking
and checking back frequently!
I think the admin of this web site is really working hard in support of his web
page, for the reason that here every material is quality based information.
I value the post.Really thank you! Will read on…
Simply want to say your article is as amazing.
The clearness in your post is simply nice and i could assume you are an expert on this subject.
Well with your permission allow me to grab your RSS feed to keep up to date with
forthcoming post. Thanks a million and please keep up the rewarding work.
What’s up to every , for the reason that I am actually eager of reading this blog’s post to be updated regularly.
It carries nice stuff.