What Selector Nesting in Sass is used for?

Technology CommunityCategory: CSSWhat Selector Nesting in Sass is used for?
VietMX Staff asked 3 years ago

Sass let you nest your CSS selectors in a way that follows the same visual hierarchy of your HTML. CSS, on the other hand, doesn’t have any visual hierarchy.

Consider example (scss):

.parent {
  color: red;

  .child {
    color: blue;
  }
}

Result (css):

.parent {
  color: red;
}

.parent .child {
  color: blue;
}