The &
parent referencing sign can be used multiple times in the same selector to reference the same parent. For instance, multiple parent references can be used to construct child and sibling combinatory selectors.
You can compile the Less code in this recipe with the command-line lessc
compiler, as described in the Installing the lessc compiler with npm recipe in Chapter 1, Getting to Grips with the Basics of Less.
Write the following Less code into a file and compile this file with the command-line
lessc
compiler:p { color: green; & + & { color: red; } }
You will find that the preceding Less code will be compiled into the CSS code, as shown in the following code:
p { color: green; } p + p { color: red; }