As the web continues to progress more people are turning to CSS pre-processors to help style their web applications.
Although there are several options there’s no doubt that two of the most popular pre-processors are Sass and Less. By using these programs web designers can practice nesting, use mixins, and other features in order to rapidly style web pages.
But people often come to a crossroads when choosing which preprocessor to use. Therefore I’ve compiled this article to give you deeper insight about both Sass and Less, with the hope of helping you determine which CSS pre-processor is right for you.
Sass
Since first being developed in 2007, Sass has become the most widely known CSS pre-processor of them all – and for good reason. Although it’s been around for nearly a decade the tycoons behind Sass continue to extend its functionality.
It is currently in version 3.4.x and will only continue to progress. Where Sass really excels is in the framework category. Developers can use Sass with frameworks such as Bourbon and Compass, which provide Sass programmers additional functionality.
For example, the Compass framework provides the following mixin for styling links.
link-colors($normal, $hover, $active, $visited, $focus)
By passing in values to this mixin, Compass will generate five different styles for all of the links inside your layout. Although this is just one case it exemplifies how useful frameworks such as Compass can be.
Less
Two Years after the release of Sass another CSS pre-processor arrived on the scene. The Less ruby gem was developed in 2009 as an alternative to Sass and has since been rewritten in JavaScript.
Although it does not make much of a difference, some people prefer to use JavaScript over Ruby. That said, Less provides functionality very similar to that of Sass. However the syntax is a bit different.
Whereas Sass uses the $
symbol for variables, Less uses the @
, which is the sign Sass uses for mixins. If you want to check out a side-by-side syntax comparison you can view them through this link. One thing that Less provides which Sass does not is the use of Namespaces, which you can see an example of below.
bundle () { .red { background-color: red } .green { background-color: green } } .foo { #bundle > .red; }
Once processed, the code above would produce the following result:
.foo { background-color: red; }
The purpose of namespaces is to group mixins together; but as you can see, this can become a little confusing. Therefore the core developers of Sass decided against including this feature.
Nonetheless it still shows the power that Less gives you when styling a web page.
Conclusion
You may still be wondering what preprocessor is right for you. In the end the choice is ultimately yours.
However I personally believe that the frameworks, specifically Compass, make it extremely easy to write in Sass. It provides a number of mixins that are created to make your life as a web designer easier. Regardless of which preprocessor you decide to use, use it well, as each is extremely powerful in the right hands!
The post Sass vs. Less: A Comparison for Frontend Developers appeared first on webdesignledger