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 888665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:26:13+00:00 2026-05-15T13:26:13+00:00

Using sass, how do you style #box1 img, #anotherbox img { height: 80px }

  • 0

Using sass, how do you style

#box1 img, #anotherbox img { height: 80px }

? Is using mixins the only way?

  • 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-15T13:26:14+00:00Added an answer on May 15, 2026 at 1:26 pm

    One way is to list your selectors just as you have done in CSS: but that’s not the Sassy way to do it since these elements don’t necessarily relate to each other, so why should they belong together? They just happen to share some common styles. Listing them together like this works fine, but is slightly harder to keep organized as you add more:

    #box1 img, #anotherbox img
      height: 80px
    

    You could of course use a mixin for that if you want to generalize it:

    =shorty
      height: 80px
    
    #box1 img, #anotherbox img
      +shorty
    

    But it’s the same thing: #box1 and #anotherbox want to be in different parts of the file. You need them to share some common styles, but it makes more sense to keep them organized with the group of box rules to which they belong so you split them up:

    =shorty
      height: 80px
    
    #box1
      img
        +shorty
    
    #anotherbox
      img
        +shorty
    

    Since that calls the mixin twice, it creates duplication in the output:

    #box1 img { height: 80px }
    #anotherbox img { height: 80px }
    

    This is perfectly acceptable when the mixin just has a few rules in it, or when it’s used in a limited number of places. (Mixins really come into their own when the mixin generates different style rules based on parameters.)

    Ok, so that’s the trip around the block with mixins.

    Here’s how you avoid that duplication using @extend:

    The idea of @extend was originally proposed by Nicole Sullivan in her CSS Wish List blog post. This seemed like such a good idea that an implementation in current plain CSS was devised, and it was added to Sass shortly thereafter.

    If your style rules describe a pattern that’s intended to be used as a general class or a base style for a number of other items, you should consider @extend.

    To understand the difference, we know a mixin will output the styles each time it’s called, but extend will instead create a list of all the selectors where that style is used, and then attach them to one style block:

    .thumb-size
      height: 80px
    
    #box1
      img
        @extend .thumb-size
    
    #anotherbox
      img
        @extend .thumb-size
    

    Produces:

    .thumb-size, #box1 img, #anotherbox img { height: 80px }
    

    It will print the base style class (.thumb-size) in the output, even if you strictly don’t need it for anything else. But, I think this is preferable anyway since it defines the purpose of that list of selectors when it’s sitting in front of them.

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

Sidebar

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.