LESS - Extend "all"



Description

When the keyword all is identified at last in the extend argument, then LESS matches that selector as part of another selector. The selector part which is matched will be replaced with extend, making a new selector.

Example

The following example demonstrates the use of all keyword in the LESS file −

extend_all.htm

<!doctype html>
   <head>
      <link rel = "stylesheet" href = "style.css" type = "text/css" />
   </head>

   <body>
      <div class = "container">
         <h3>Welcome to TutorialsPoint</h3>
         <div class = "style">
            <ul class="nav">
               <li>SASS </li>
               <li>LESS</li>
            </ul>
         </div>
      </div>
   </body>
</html>

Next, create the style.less file.

style.less

.style.nav,
.nav h3 {
   color: orange;
}

.nav {
   &:hover {
      color: green;
   }
}
.container:extend(.nav all) {}

You can compile the style.less file to style.css by using the following command −

lessc style.less style.css

Execute the above command; it will create the style.css file automatically with the following code −

style.css

.style.nav,
.nav h3,
.style.container,
.container h3 {
   color: orange;
}

.nav:hover,
.container:hover {
   color: green;
}

Output

Follow these steps to see how the above code works −

  • Save the above html code in the extend_all.htm file.

  • Open this HTML file in a browser, the following output will get displayed.

Less Extend
less_extend.htm
Advertisements