Member-only story

CSS vs SCSS

Sumit kumar Singh
3 min readMar 5, 2023

CSS and SCSS are both styling languages used for creating the visual appearance of web pages. SCSS stands for Sassy CSS and is a preprocessor that adds features and functionality to CSS, making it more efficient and easier to work with.

Here is an example of CSS and SCSS for styling a simple button element:

CSS:

button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}

SCSS:

$button-bg-color: #4CAF50;

button {
background-color: $button-bg-color;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}

As you can see, the SCSS code uses a variable $button-bg-color to store the background color of the button, which can be reused throughout the code. This makes it easier to change the button's background color in the future by simply updating the value of the variable, rather than having to search through the code and update each instance manually.

Additionally, SCSS allows for nested selectors, which can make the code more organized and easier to read. For example, you can write:

--

--

Sumit kumar Singh
Sumit kumar Singh

Written by Sumit kumar Singh

YouTube: https://shorturl.at/8zZ4B Topmate: https://topmate.io/sumit_kr_singh 📚 HTML, Angular, React, and JavaScript 🧑‍💻 Tips & tricks

Responses (2)