Sass Introduction To Web Designers

SASS introduction to Web Designers

As much as everyone loves writing styles in CSS, but lets face it, there are no smart options to write code in it. There is repetition of similar code all over our stylesheet for different selectors. Taking up much time and effort. If the hex value of a color has to be changed in the entire document, the process is a manual one, much like a linear search. The vendor prefixes that impart such cool effects after rendering, makes developer write long redundant code for every browser support.

Preprocessors like SASS, Less , etc. targets these pain points and comes up with ways to ease up the process of writing and maintaining huge amount of CSS. It doesn’t replace CSS by any means. It adds a cleaner syntax and useful additional functionalities.

Say Hello to Syntactically Awesome Style Sheet!

SASS introduces features such as Nesting, Variables, Mixins , Control Statements, Mathematical operators, Inheritance & better in-built functions to increase the utility of CSS furthermore, making it a designer’s programming language.

1. Nesting

Instead of repeating selectors’ list over and over, it allows nesting selectors and rules. It makes the structure of the stylesheets similar to the DOM structure.

Although it is a good practice to avoid nesting elements more than 3 levels deep as to prevent making the css too rigid!

2. Variables & Operators

The simple yet powerful feature borrowed from programming languages can make writing css a relief! Values that has to be reused throughout the stylesheet can be stored in them. One can store things like colors, font stacks, or any CSS value that has to be reused. It is also possible to do mathematical operations with them.

Now if the brand color has to be changed, there won’t be a need to make countless changes in the css, just change the value of a single variable and its done!

3. Mixins

These are a reusable block of code which can be mixed in to another ruleset with ease. It also accepts arguments.
They give us the ability to build a reusable library of styles, but most commonly used for vendor prefixes.

It is considered a good practice to refactor & abstract the methods behind successful techniques to make them reusable for next projects.

5. Imports

For management of complex and huge stylesheets,designers split their style sheet up into several smaller CSS files and then import those style sheets from within the main stylesheet.
Every import statement will generate a separate HTTP request.

Now, @imports have long been a part of CSS, then what is new about the SASS version of it?

SASS combines these imported files with the main stylesheet, and serves a single file to the browser.

Getting started with SASS is easy.Switching to a preprocessor make development and maintenance easier. It makes the code modular, organized , non-repetitive, lighter to load and lets you make your own custom functions in CSS.