You may have heard of pre-processing of CSS and wonder what all the buzz is about. You may have even heard of Sass or LESS. In summary, the pre-processing CSS allows you to write concise style sheets that are formatted well and require less repetitive techniques that are commonly found when writing CSS code. The result is a more dynamic style and an ample amount of time saved in developing websites or applications. If you write CSS, then you can easily learn how to pre-process your CSS. Once you understand the scope of Sass, wonder why is not changed before.
CSS vs Sass vs SCSS
How is it different from CSS Sass?
Sass seems similar to CSS, but it has its obvious differences instead of diving There are two ways to write and Sass is ultimately up to you which style you prefer. I use the style of indentation and brackets (. SCSS) in my projects because I really like to visualize where a block begins and ends when a large amount of code becomes nested. After processing the Sass CSS code compiled automatically by a traditional pre-processing engine.
There are many applications available that allow precompiling your Sass perfect and downright easy. To install, you can use the command line, provided you have Ruby installed on your machine. If you are not comfortable with the command line, there are other options (more on this later) and if this is over your head Sass-lang.com visit to learn how to do this in a simple step by step format. In the end, anyway either command line or application, installation Sass and automatically monitor changes to the traditional CSS compile for you.
I recommend using applications like CodeKit, LiveReload or Mixed that help you set up a project on a Mac Sass from the beginning or if you are a Windows user PrePros, CodeKit, my choice preprocessor, support me by my Sass preprocessing and validate and minifying your code to allow your web site to work quickly and effectively. (The ability to create Compass or Bourbon CodeKit based projects is also an awesome feature, but is beyond the scope of this article.) After you feel more comfortable with Sass sure to check how to use Compass and Sass Bourbon in their projects.
If you’ve been following our earlier, we less posts, we are sure that you are familiar with CSS Preprocessor. Both Sass and LESS CSS preprocessors are extending especially how we compose plain-static-dynamic CSS as use programming languages like variables, mixins and functions. Before we can compose Sass have to install it. Sass is based on Ruby. If you are working on a Mac, chances are, you already have Ruby installed. If you can install Ruby on Windows, use the installer of Ruby. After installation is complete, you can go to the terminal (on a Mac) or command prompt (on Windows) and then type the following command at
In Mac; sudo gem install sass
In Windows; gem install sass
If you are working with Sublime Text 2 like I do, you can use These packages; Sublime Text HAML and Sass & Sass Sublime Text 2 Package, and for an Easier way, you can install one of These packages through Package Control.
Sass vs. SCSS: which syntax is better?
Since the creation of Sass nearly 5 years ago, it has-been plagued by many levels of controversy. It billed itself as “a better CSS” and added unheard of brand new features to CSS authors: such as variables, mixins and nesting. Sass Also Introduced an Entirely different indentation-oriented syntax and a brand new perspective on how to author CSS.
The Sass syntax
The indented syntax of Sass was inherited from its first-born brother Haml. And while Sass and Haml eleven got along – Hey, They even shared the same Ruby Gem! – Caused dissension in the family to split the two languages and Their go separate ways. Each seeking its own fame and fortune in the land of Open Source opportunity. One common objection Among detractors Sass Is that the indented syntax is so foreign to CSS.
Why spend the time learning a language radically different from That is CSS? This difference, They Fear, will make it hard for them to continue to REMAIN fluent in a language with as many nuances and subtleties as CSS. What if Sass is just a fad? What if it does not last? What if it does not gain traction Among the masses? What if all newly Formed Their code and best practices fall by the wayside Should the “downfalls” of Sass.
Pros for SCSS
Reason # 1: SCSS is more expressive
No really! I know I Argued That Sass above is Easier to read Because of the way it forces you to write your rules and attributes with indentation, but after coding for a while in SCSS’ve Realized That I really like having the option to put a couple of attribute / value pairs on the same line. I do not always write it this way. Normally, I write in expanded format With An attribute / value pair per line. But the compressed syntax is helpful When I only have an attribute / value pair or two. I especially like it for changing the color of a font for a hover state or adding a link to an underline.
Reason # 2: SCSS encourages you you proper nesting of rules
One of the huge advantages of Sass in General Is that it Allows you to nest selectors selectors Within. Because this is awesome When you change the “name” of an element, you only need to change it in one place (the outer dial) instead of in multitude multitude numerous places you would like When writing CSS.