Skip to content

Instantly share code, notes, and snippets.

@tortillaj
Last active August 29, 2015 14:20
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 tortillaj/3d47780c5d5954cca9af to your computer and use it in GitHub Desktop.
Save tortillaj/3d47780c5d5954cca9af to your computer and use it in GitHub Desktop.
Nesting classes and Elements in Sass
<div>
<h1>Nesting classes and elements</h1>
<p>Elements and classes can be nested. Here we nested a paragraph tag. <a href="#">Links can be nested too.</a></p>
<p class="highlighted-text">Classes can be nested too!</p>
</div>
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
// set a global variable
$myColor: #4d4d4d;
div {
p {
color: $myColor;
}
a {
color: $myColor;
text-decoration: underline;
}
.highlighted-text {
color: pink;
}
}
div p {
color: #4d4d4d;
}
div a {
color: #4d4d4d;
text-decoration: underline;
}
div .highlighted-text {
color: pink;
}
<div>
<h1>Nesting classes and elements</h1>
<p>Elements and classes can be nested. Here we nested a paragraph tag. <a href="#">Links can be nested too.</a></p>
<p class="highlighted-text">Classes can be nested too!</p>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment