Home » Less Parent Selectors

Less Parent Selectors

by Online Tutorials Library

Less Parent Selectors

In Less, the parent selectors are denoted by &(ampersand) operator. The parent selectors of a nested rule are represented by & operator and is most commonly used when applying a modifying class or pseudo-class to an existing selector.

A list specifying the types of parent selectors:

Index Types Description
1) Multiple & The & is used to represent nearest selector and also all the parent selectors.
2) Changing Selector Order It is used to change the selector order because prepending a selector to the inherited (parent) selectors is useful when selector ordering is changed.
3) Combinatorial Explosion The & operator can also produce all the possible permutation of selectors in a list. The selectors in the list are separated by commas.

Parent Selectors Example

Let’s take an example to demonstrate the usage of parent selectors.

Create a HTML file named “simple.html”, having the following data.

HTML file: simple.html

You may also like