6 Reasons to Start Using SASS

Postat pe - Modificat ultima dată pe

Learning CSS isn’t easy. From understanding each property of the cascade to the complex interface, all of these took time, and most developers use CSS only because, well, they already spent the time on it, so might as well use it.

As the development of apps and webpages become more and more complex, style sheets get larger and harder to maintain. Preprocessors such as Sass (Syntactically Awesome Stylesheets) make style sheets concise while allowing codes to retain their module, and there are some hacks in Sass that are not available in regular CSS.

Why use Sass?

  • Compile without changing anything. If you want an organized style sheet, then Sass will help you set up. Since the syntax of Sass is a superset of CSS3, there are no changes to the way you normally write CSS. Most codes and formatting preferences remain the same.
  • Organize the team. If you are a part of a team of front-end developers, preprocessors such as Sass are great to use. All your huge CSS files can be structured as a result.  The features of Sass can be used to structure all of your team’s style sheets and organize them into CSS chunks for easy organization.
  • Color functions are direct. As a beginner, you might think that functions for preferences such as colors might become complex. In Sass, the syntax is straightforward; you can manipulate the color, be it RGB, hexadecimal, or any CSS color format; modify the amount, to make it lighter or darker; and set preferences, like alpha.
  • Using Mixins to organize. CSS can be a bit long and hard to write. In Saas, you can use mixins. This makes groups of style sheet declarations that you can reuse throughout the site. Instead of typing a property over and over, you can instead prepare a mixin and then code it any time you need it. Mixins are even flexible, and you can use arguments with it.
  • @import is much more useful. There is a @import function in CSS, but the one on Sass is different. For a Sass @import, the preprocessor pulls a style sheet file before it compiles the CSS. This way, you can break your style sheets into chunks while only serving one page to the browser. If you need to fix something, you don’t have to search the entire style sheet to look for that line.
  • Variables. Sass provides variables to store information that you want to write all over the style sheet. You can store color values or a long font stack, and then name them as variables. This way, instead of writing them again for another page, you can just use the variable. Declare it by using a dollar sign followed by the name.

If you are still unsure of whether to use Sass or not, try to code it out on a test site first to get a feel for it. Check out the pros and cons, and if it meets your requirements. This way, if you prefer to work with it, then you can start compiling using Sass. If not, there are other preprocessors available, or you can just go back to using standard CSS style sheets.

Postat: 10 martie, 2015


Freelance Writer

Passionate about anything and everything, zest for life translates to both writing, travel, and new discoveries whenever and wherever that may be.

Următorul articol

6 Tips for Writers on Making Effective Pitches