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 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
Control Scrolling with CSS Scroll SnapCSSSQL Right JoinSQL/MySQLHow to Draw a Circle in HTML5 Using Canvas Tag?HTMLOOP, Class and Objects Strategies For Beginners (PHP)PHPHow to get the height and width of an element using JavaScript?JavaScriptHow to display random posts in WordPress?WordPressHow to add a select dropdown in React?ReactRevisiting variable scope in JavaScriptJavaScriptWordPress Plugin: Things to knowWordPressHow to vertically align a html radio button to it’s label?CSSThe flex-grow, flex-shrink and flex-basis Properties in CSSCSS6 Different Functions to Sort Arrays in PHPPHP