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 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 90,717 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 90,717 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. :-)