SASS or SCSS for beginners.
Tags: scss, sass, beginners, tutorial
Published: 2022-04-05 15:22:54

## SCSS vs SASS -

**_In order to understand each and everything you need to have knowledge of CSS_**

- SASS (Syntactically Awesome Style Sheets) is a pre-processor scripting language that will be compiled or interpreted into CSS. Sass Script is itself a scripting language whereas SCSS is the main syntax for the SASS which builds on top of the existing CSS syntax.

- In CSS3 we call SASS as SCSS.

- We are going to use VS code so install it.

- Once done install the extension shown below.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cspf5y2319w9glp6b63n.png)
 
- Once you are done with the installation of that extension you will be able to see a button at the bottom of your editor's screen.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7srs1f2db50t1njhbj0j.png)

 - Now let's have a look at the folder structure you need to maintain to work with the SCSS.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8or1i37k07kgbrhd0aad.png)

- Now click on that button on the bottom about which we talked earlier.

- This will compile your SCSS code to the normal CSS code because the browser won't be able to understand SCSS that's why we need a compiler.

- And after compilation, your folder structure will change and you get a CSS file too in your folder.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrt65n5kuvamvm3x2lp1.png)

- This was the setup and some basics you need to be aware of.

**Since you all are aware of CSS so let's have a look at the feature which makes it different from CSS3**

### 1- Use of operators -

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmmif9bp0uyjie53no30.png)

-  Here we used the "+" sign to add two values so here is what will happen? actually, they are going to behave like "10rem".

- If you visit your compiled CSS file there you will get something like this.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bnpq97jo28jdjyo0cy2d.png)

 - Similarly we can use "*", "/", "-" too.

### 2 - SASS Variables -

- Now variables are included in CSS too.

- Syntax to declare a variable in SCSS.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2euys6z68gniwk2nm5x.png)

-  Dollar sign variable name and then its value.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s623ucfum3oo6dbfl91j.png)
 
- And it can be used like this.

### 3 - Nesting -

- If any component has its child then they can be styled within their parent's syntax as shown below.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7dsh528lfwo2u480sg9.png)
 
- We can take it a step further.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7rez5swiokzcnzipasa.png)

### or

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aimug0g3l6fwwp08948g.png)
 
### 4 - Mixin -

- Suppose you know that there is a property of CSS you gonna use for lots of time in this case mixin helps you.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xqvtt15ynwxuic6paw8.png)
 
![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5i31ofw3pgng3s3gdtmc.png)
 
- First defined and then used that property.


### 5 - Parameters -

- Now suppose we created a mixin of some common styles but their values need to be different in different places then we can pass a parameter in the mixin as shown below.
 
![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1n6dkjvrqftwo3ae0q8q.png)

- Now, whenever we use we just need to pass a parameter.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ud67hmolq4gvn0njvxa.png)
 
- The order of parameters matters in the order in which parameters are defined their values need to be passed in the same order.

### 6 - SCSS Partials-

- It means that instead of writing all the styles on one page we can use different pages too, for example, we can use different pages for mixins, and variables and we can call them when required.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6ixd9daca6rihesiaco.png)
 
- Partials names should start from underscore so that compiler doesn't compile them.

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kcdsgtor4tat8xy4bv7u.png)

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oo17zvip2zw3c34utggu.png)

- Now let's see how we can get that partial files in our main CSS files.
  
![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psyfmekcrzk7iu78yy1z.png)
 
- At the top of your **"main.scss"** file import them. ( we don't need to include the file extension and underscore here ).