what the use of Nesting?

Answer

CSS supports logical nesting, but the code blocks themselves are not nested. Less allows nesting of selectors inside other selectors. This makes inheritance clear and style sheets shorter.

#header {
  h1 {
    font-size: 26px;
    font-weight: bold;
  }
  p { 
    font-size: 12px;
    a { 
      text-decoration: none;
      &:hover { 
        border-width: 1px;
      }
    }
  }
}

The above code in Less would compile to the following CSS code:

#header h1 {
  font-size: 26px;
  font-weight: bold;
}
#header p {
  font-size: 12px;
}
#header p a {
  text-decoration: none;
}
#header p a:hover {
  border-width: 1px;
}

 

All less Questions

Ask your interview questions on less

Write Your comment or Questions if you want the answers on less from less Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---