STOP writing CSS, 10 reasons why
Tags: css, webdev, design, html
Published: 2020-10-26 15:10:58


##Prefer video?

{% youtube rlLI_ndLbRo %}

In this brief article a want to give you some reasons why you should stop writing CSS and start writing SASS.

At the end the output is the same a cool and well minified .css file.

The order of the list isn't important!

## 10 ~ Syntax

When you write SASS code you will see the difference instantly when you see that the code is a lot cleaner without brackets and semicolons, that matters here are tabs.


![Syntax of css compared with sass](https://dev-to-uploads.s3.amazonaws.com/i/9jt680548133x4i5n1sr.jpg)

When you write nested selectors you will have an easier time watch this 😁️

![Clean parent to selector sass compared to css](https://dev-to-uploads.s3.amazonaws.com/i/9vfp1tz7ah0c32i4egsk.jpg)

## 9 ~ Variables

That thing was really needed in CSS... the use of variables that will help you a lot to manage your code and even for future refactoring.

For example you can create a palette.sass file and store all your colors and then call that variable inside your buttons or divs...

The most beautiful thing in my opinion is that just changing one line of code (where you have defined the color variable) you can change the color of your entire application.

Take a look here 👇
![Variables in sass compared to css](https://dev-to-uploads.s3.amazonaws.com/i/r4450j2efcmk4hzqse79.jpg)

## 8 ~ Mixins

Really cool stuff, mixins help you to define reusable portions of code, you can think of them like functions, you can pass a parameter and get back you block dynamically written

![Mixins in sass](https://dev-to-uploads.s3.amazonaws.com/i/n86lwihom0mldx94y7zy.jpg)

## 7 ~ Functions

mmm.. yes mixins and functions are really similar... but, but with functions you can return something with mixins you have only a predefined block of code

## 6 ~ Imports

Instead of having a super big main.css file with 200000 lines of code split by strange ### signs with titles or worst stuff you could import and export you sass files.

It is not the same thing as the link rel thing cause when you do that you are making an HTTP request :D

You will have a beautiful structure of your code for example with

* header.sass
* menu.sass
 * profile_image.sass
* footer.sass

You can even import CSS files!!

![The use of imports in sass](https://dev-to-uploads.s3.amazonaws.com/i/njre0nc5x7p66msvgpfv.jpg)

## 5 ~ Maths

With sass you can do pretty any operation you want, that was a big limitation with only css, now no more!

![Math operations with css](https://dev-to-uploads.s3.amazonaws.com/i/ydr64asmqgk53gnfzxud.jpg)

## 4 ~ Logic

Another thing missing in CSS is the logic, with SASS you have the possibility to use if statements, for while.

That will help you to write less code with more ease.

![Example of is statement with sass](https://dev-to-uploads.s3.amazonaws.com/i/ncfskn3h6nvu8evbbem5.jpg)

## 3 ~ Clean and easy to read code

Maybe i have said it a lot of times but really, with SASS you will see a beautiful code.

Using the combination of mixins imports variables no way that is like css, you code will be really clear to understand.

The only fact that you have different files that contains different parts of you code it will help you when you want to change something in the future.

For example image that you want to change the main color with css... or the font family

## 2 ~ Faster development

Clean code means fast development, one of the things that IMHO slowed me a lot was semicolons, and another thing... semicolons, i really hated semicolons...

You can use mixins without having to repeat over and over parts of code respecting the dry principle.

## 1 ~ Production ready

You will get as output a clean css file the way that you want, if you want multiple css files is up to you.

You CSS will be minimized and ready to be imported...


## That's it

I hope that you enjoyed this article, it is my first article, i hope that that stuff my help someone and thanks for reading... 

Let me know if you want to know how to install SASS with a youtube video or things like that...

If you enjoyed my style check out my new [Youtube Channel](https://www.youtube.com/channel/UC9FtVivCn-y_YFIxffP-qXQ) 

Thank you for your time, have a good day 👋😁