Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to group CSS selectors for clarity?

If I have a dozen CSS selectors, and want to assign :hover properties to all of them, I'm used to doing this:

selector, selector2, someOtherSelector, someSelector div {
    //some properties
}
selector:hover, selector2:hover, someOtherSelector:hover, someSelector div:hover {
    //some properties
}

Typing :hover four times seems redundant. Is there a way to group the selectors like

(selector, selector2, someOtherSelector, someSelector div):hover {
     //some properties
}

instead?

like image 711
Isaac Lubow Avatar asked Jan 25 '11 03:01

Isaac Lubow


1 Answers

Not natively in CSS. By using something like SCSS, you can write:

selector, selector2, someOtherSelector, someSelector div {
  // some properties

  &:hover {
    // some more properties
  }
}
like image 76
Sophie Alpert Avatar answered Oct 16 '22 05:10

Sophie Alpert