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

CSS Sass Basics Improve Your Workflow with Sass Write Nested Selectors

Nest a .button selector inside the .banner rule. Set the font-size of .button to 1.5em

Nest a .button selector inside the .banner rule. Set the font-size of .button to 1.5em. need help

style.scss
.banner {
  padding: 1em;
  background-color: lightgrey;
}
.button{
font-size:1.5em;
}

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Hi Carol,

So at the moment what you're doing is writing 2 independent styles in the same way you would a standard CSS file. So if you were to compile that with CSS it would give you exactly the same output.

If you cut and paste the banner style rule and put it before the closing curly brace that should give you different CSS output. That's what nesting is, a selector that goes inside another selector.

hie Jonathan if u can please write the code down for me i have tried the way u said still getting wrong

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,252 Points

Okay, before I do that let's just go over again what we talked about with nesting.

Nesting doesn't mean anything to CSS. It's just a way of organising code in SASS so it can output CSS in a way you normally would see in a CSS file.

.banner {
  padding: 1em;
  background-color: lightgrey;

   .button{
      font-size:1.5em;
   }

}

If you organise the code as seen above you'll see what I mean. See how the .banner style contains yet another style rule?

If you tried something like this and it didn't work my guess is you tried a slightly different property and/or value to the one the challenge was expecting. :-)