Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Marcus Tisäter
Marcus Tisäter
4,886 Points

Adding important property to sass mixin

hey

I made this mixin

     @mixin block($color,$font-size,$font-weight) {
           color: $color;
           font-size: $font-size;
           font-weight: $font-weight;
     } 

I include the mixin...

          @include block(blue,15px,bold);

I want to add the !important property for the color, I dont know how to input it, i keep getting SASS syntax errors. Any ideas?

6 Answers

Yaswanth Goli
Yaswanth Goli
6,872 Points

keep semi-colon at font-weight

Marcus Tisäter
Marcus Tisäter
4,886 Points

You can include the !important throughout the include by doing this

  @include block(blue !important,15px,bold);

Can you do it at a mixin?

Yaswanth Goli
Yaswanth Goli
6,872 Points

try @mixin block($color,$font-size,$font-weight) { color: $color !important; font-size: $font-size; font-weight: $font-weight; }

Marcus Tisäter
Marcus Tisäter
4,886 Points

That worked... It's wired becuase in CSS you have to use : after a property value to include !import ...

Wayne Priestley
Wayne Priestley
19,579 Points

Hey Marcus,

I'm curious as to the reason for needing !important in your mixin, I assume that being a mixin you intend to use this a lot, so are you running into a problem getting the colour to apply without !important?

cheers

Marcus Tisäter
Marcus Tisäter
4,886 Points

It's a long story.. , but I need the !important to overwrite a diffrent colour set that keeps being primary. I manage to get it work now!