BENEFITS OF USING SASS OVER CONVENTIONAL CSS
By ADMIN| September 11, 2018
CATEGORY : BLOG | BLOG DYNAMIC | DEV
TAGS :
Definitely you require the help of CSS (Cascading Style Sheets) to describe how HTML elements must be displayed on a web page to define styles, design, layout almost everything you need to create a stunning website.But when you start working with large, complex sites, you might start to wonder if CSS could be better. Or if there is any other option. Well, there is. Let’s work out with SASS.
What is SASS?
SASS (Syntactically Awesome Stylesheets) is a CSS pre-processor that lets you use variables, mathematical operations, loops, functions, imports and other functionalities that make CSS powerful from earlier. In some ways, you may think of SASS as a style sheet extension language. This is because it extends the standard CSS characteristics as it introduces the benefits of a basic programming language. So SASS will compile your code and generate the CSS output a browser can understand.If you are a programmer, it will only take you 15 minutes to get SASS. But if you are totally new in coding, then you may find a bit complicated. Once you learn CSS with SASS, you won't write CSS from scratch anymore.Here are the benefits of using SASS:
It's CSS syntax friendly
If you know CSS, you wouldn’t have problem in learning SASS. SASS comes with two different syntaxes: SASS itself and SCSS, the most used one. SCSS syntax is CSS compatible, so you just have to rename your .css file to .scss. Your first SCSS file has been created, just like that.Although it is not anything big or you are not using any abilities SASS provides, but at least you realize you don't need to spend hours and hours to start using SASS. From this starting point, you would be able to learn the SASS syntax as you go.Offers variables whatever you want
One of the great benefits of using a CSS pre-processor like SASS is the ability to use variables. A variable allows you to store a value or a set of values. You can reuse these variables throughout your SASS files as many times you want and wherever you want.Imagine a scenario in which you're building a site with blue colour everywhere - buttons, menus, icons, containers, etc. You're also using a couple of fonts: Ubuntu and Nunito. Using traditional CSS, you would need to repeat the same code over and over, but with SASS you can store these values as variables:Once you have created the variables, you can use them wherever you need to, like this:When you compile your SCSS files, SASS will replace the variable name with its stored value. Changing the value of the color is as quick as updating the variable content and re-compiling.It uses nested syntax
Another benefit of CSS pre-processors is their improved syntax. It allows you to use a nested syntax. It is code contained within another piece of code that performs a wider function. Here nesting allows a cleaner way of targeting elements.Benefits of nesting:- More natural syntax and easy to read
- Prevents the need to rewrite selectors multiple times
- Better code organization and structure
- More maintainable code.
- Overly specific CSS rules that are hard to maintain
- Selectors that cannot be reused
- Performance issues.