Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nesting > (greater than) in Less-CSS

In LESS-CSS, this:

.a {
  .b {
    font-color:red;
  }
}

is equivalent to

.a .b {
  font-color:red;
}

Is there an nested equivalent of > ?

.a > .b {
  font-color:red;
}
like image 666
ripper234 Avatar asked Feb 21 '12 13:02

ripper234


People also ask

How do you refer to a parent in nested rules inside Less?

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.

Is nesting allowed in CSS?

When we use a CSS preprocessor like Sass or Less, we can nest a CSS style rule within another rule to write clean and understandable code. This nesting rule is not supported yet in native CSS. At the moment, it is a working draft and only available for discussion.

What does '>' mean in CSS?

The greater than sign (>) selector in CSS is used to select the element with a specific parent. It is called as element > element selector. It is also known as the child combinator selector which means that it selects only those elements which are direct children of a parent.


1 Answers

This does it:

.a {
  > .b {
    font-color:red;
  }
}
like image 160
thirtydot Avatar answered Oct 29 '22 00:10

thirtydot