Yogesh Chauhan's Blog

Selector Lists and Combinators in SCSS (Sass)

in SCSS on April 25, 2021

We know about basic nesting in SCSS (SassScript) but there is so much more than just basic nesting.

Selector Lists

Selector lists are nothing but comma-separated selectors. If you want to apply same nesting rule for more than one selectors, SCSS gives you an easy way to do it.

Just like this:

Each selector in the list is nested separately and then combined into a selector list.

Here’s the compiled CSS:

.alert ul, .alert p, .warning ul, .warning p {
    border: 1px solid white;

Selector Combinators

We can use nesting for the selectors that use combinators.

Just like this:

Here’s the compiled CSS:

ul > li {
  list-style-type: none;

h2 + p {
  border-top: 1px solid gray;

p ~ span {
  opacity: 0.8;

Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
PHP Login System using PDO Part 1: Create User Registration PagePHP3 ways to pass a variable in url() function in SCSS (Sass)SCSSIntroduction to components and templates Part 1: Component MetadataAngularPHP Login System using PDO Part 2: Login using Email or UsernamePHPForcing the domain to serve securely using HTTPSMiscellaneousTackle Accessibility in React with JSXReactAttributes and Properties in JavaScript and HTMLHTMLHow to create and store JSON objects in localStorage using JavaScript?JavaScriptHow to use PHPMailer to send an Email via Gmail SMTP Server?PHPHow to create a simple drop down menu using JavaScript and CSS?CSSHow to add transparent text on top of an image using CSS?CSSHow to modify AutoSave Interval using code in WordPress?WordPress