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 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

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
WordPress: How to set WP_SITEURL?WordPressWordPress: How to print ACF repeater field values?WordPressSolution to “TypeError: ‘x’ is not iterable” in Angular 9AngularCreate a responsive image gallery using CSS gridCSSHow to host Google fonts on your server and add them using CSS?CSSA Step by Step Guide to Make RSS in XML For Any Website or Blog For FreeMiscellaneousRecursive WITH Queries in Postgres (Common Table Expressions)PostgresHow to render Lists in React?ReactHow to Use ROLLUP Operator in SQL and MySQL?SQL/MySQL2 Ways we can create an Array in JavaScriptJavaScriptComposing and Extracting Components in ReactReactAll possible ways you can Insert Data in PostgresPostgres