Skip to Content
Pragmatic Guide to Sass 3
book

Pragmatic Guide to Sass 3

by Hampton Lintorn Catlin, Michael Lintorn Catlin
July 2016
Intermediate to advanced
130 pages
2h 11m
English
Pragmatic Bookshelf
Content preview from Pragmatic Guide to Sass 3
34Escaping Indentation with @root

Sometimes, for code clarity, we want to keep our styles close together. And this might mean that we’re in the middle of a nested block of Sass when we really want to be outside of it. This is where @at-root comes in handy.

In our example, we have a header icon we want to style. It’s mainly found in the header, so we want to associate the icon with those styles. However, we might want to use the icon elsewhere, so we’d really like the styles to be more global. We use @at-root to flatten the nesting and make .icon at the root of the document.

There aren’t a lot of use cases for @at-root—moderating our nesting is an equally appropriate solution. However, there are a couple of situations that people have found ...

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

Jump Start Sass

Jump Start Sass

Hugo Giraudel, Miriam Suzanne
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Mastering Sass

Mastering Sass

Luke Watts

Publisher Resources

ISBN: 9781680502060Errata Page