Skip to Content
Jump Start Sass
book

Jump Start Sass

by Hugo Giraudel, Miriam Suzanne
April 2016
Beginner
150 pages
3h 6m
English
SitePoint
Content preview from Jump Start Sass

Chapter 6Nesting

If we had to name three features that make Sass a popular stylesheet authoring tool, it would likely be variables, mixins, and nesting. As we will see in this chapter, nesting appears in several forms when it comes to Sass but by far the most popular one is selector nesting. Let’s start with this.

Selector Nesting

Selector nesting, or “nested rules” as described in the official documentation, is the ability to write rule sets within other rule sets that result in composed selectors. This is one of those concepts that are hard to describe but surprisingly easy to understand with an example.

Consider two rule sets like so:

.container {
  margin: 0 auto;
  max-width: 42em;
  padding: 0 1em;
}

.container p {
  text-indent: 1em;
}

This is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning CSS Preprocessors: With SASS, Compass.js, and Less.js

Beginning CSS Preprocessors: With SASS, Compass.js, and Less.js

Anirudh Prabhu
Mastering Sass

Mastering Sass

Luke Watts
Pragmatic Guide to Sass 3

Pragmatic Guide to Sass 3

Hampton Lintorn Catlin, Michael Lintorn Catlin
Enduring CSS

Enduring CSS

Ben Frain

Publisher Resources

ISBN: 9781457199851Errata Page