Yogesh Chauhan's Blog

How to define variables in SCSS (Sass)?

in SCSS on May 7, 2021

Sass or SCSS variables are similar to PHP variables in one way. Just assign a value to a variable name that starts with a dollar sign ($).

Just like this:

$base-color: #c6538c;

Sass (SCSS) Variables are really helpful in reducing repetition and even complex math calculation.

Sass doesn’t differentiate between hyphens and underscores when it comes to variable names. So, $font-size and $font_size both are like calling the same variable.

The SCSS code above for ‘alert‘ class compiles into this CSS:

.alert {
  border: 1px solid rgba(255, 76, 76, 0.88);
  color: #ff4c4c;

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
Overview of Drupal and how it worksDrupalPHP Login System using PDO Part 2: Login using Email or UsernamePHPHow to Clone Objects in PHP?MiscellaneousHow to use @if and @else in SCSS?SCSSCreate a responsive image gallery using CSS gridCSSHow to select an element using its ID without the high specificity of the ID selector?CSSHow to get previous days or next days in PHP?PHPHow to convert an HTML radio buttons into a toggle switch using CSS?CSSLIMIT and OFFSET in PostgresPostgres2 Ways we can create an Array in JavaScriptJavaScriptCan Firewall and IDPS Stop DDoS Attack?MiscellaneousSQL ANY OperatorSQL/MySQL