Skip to content

Instantly share code, notes, and snippets.

@CodeRecipez
Last active December 15, 2015 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeRecipez/5260697 to your computer and use it in GitHub Desktop.
Save CodeRecipez/5260697 to your computer and use it in GitHub Desktop.
Sass 101 - A newb's guide: parent selector reference

Sometimes it is necessary to extend selectors within a rule. For example, you may need extend the styling of a button to designate a fail state.

In this case, you can explicitly specify where the parent selector should be inserted using the & character.

SCSS

button {
  background: gray;
  border: 1ps solid black;
  border-radius: 5px;
  &.fail {
    color: red;
    border-color: red;
  }
}

Sass

button
  background: gray
  border: 1ps solid black
  border-radius: 5px
  &.fail
    color: red
    border-color: red

SassMeister Gist

button {
background: gray;
border: 1ps solid black;
border-radius: 5px;
&.fail {
color: red;
border-color: red;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment