Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6241031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:41:00+00:00 2026-05-24T11:41:00+00:00

In Sass, if I have a code like this div.myPanel { .btn button, .toolbar

  • 0

In Sass, if I have a code like this


div.myPanel
{
.btn button,
.toolbar
{
td, span
{
font-size: 9px;
}
}
}

I get something like this

div.myPanel .btn button td, div.myPanel .btn button span, div.myPanel .toolbar td, div.myPanel .toolbar span
{
font-size: 9px;
}

But in reality, I want

div.myPanel .btn button, div.myPanel .toolbar td, div.myPanel .toolbar span { font-size: 9px; }

Is there any better way for me to reduce the duplicate code like this

div.myPanel

{
.btn button
{
font-size: 9px;
}

.toolbar
{
    td, span
    {
        font-size: 9px;
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:41:01+00:00Added an answer on May 24, 2026 at 11:41 am

    I would suggest a minor tweak to your second form, including the .toolbar selector twice, so you’re only writing the actual rule once:

    div.myPanel {
      .btn button, .toolbar td, .toolbar span {
        font-size: 9px;
      }
    }
    

    For more in depth cases of this, you should check out @extend. Basically, if you have a class that is like:

    .base9 { font-size: 9px; }
    

    You would then convert your second example above to something like this, but note the editable style is still in one rule:

    div.myPanel {
      .btn button {
        @extend .base9;
      }
      .toolbar {
        td, span {
          @extend .base9;
        }
      }
    }
    
    #someUnrelatedElement small {
      @extend .base9;
    }
    

    Extend works by simply collapsing the selectors into one rule (like you’re looking for), so it’s great for performance in cases like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I have the following html code: <div id=parent> <div id=child> I'm the child!
So I'm working on some HTML5 code using HAML and SASS. I currently have
I am trying to get SASS to work with Rails 3. I have added
I have a number of shell scripts that all look like this: #!/bin/bash cd
I'm trying to create a Rails app template I have this block of code
I have the following mixin in a sass partial: =card-list width: 180px min-height: 150px
I really like the way padrino 'just works' with compass but I have a
I was using Sass on an existing site and decided to get Compass up
I am having a weird error when using Omniauth. This appears to have little
Is there a convenient way to have SASS automatically prepend a comment to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.