Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS Advanced Sass Advanced Variables, Mixins, Functions, and Placeholders Scoping and !default Variables

Iulia Maria Lungu
Iulia Maria Lungu
16,923 Points

this behaviour is outdated in sass 3.4.21

It should be noted that in Sass 3.4.21 (Selective Steve), this scoping works like JavaScript, exactly as the deprecation warning shown in the terminal in this video.

This :

$text-color : blue;

h1 {
  $text-color: red;
  color: $text-color;

}

h2 {
  color: $text-color;
}

compiles to this:

h1 {
  color: red;
}

h2 {
  color: blue;
}

so $text-color remains in the global scope where it was first defined

1 Answer

What he's describing in the video still works. He announces in this video that if you want $text-color: red to become its default color you must pass the !global flag after red. So,

$text-color : blue;

h1 { 
$text-color: red !global; 
color: $text-color;

}

h2 { 
color: $text-color; 
} 

compiles to

h1 { 
color: red; 
}

h2 { 
color: red; 
}