পৃষ্ঠাসমূহ

.

Search Your Article

Total Pageviews

Friday, March 3, 2017

LESS - Comments

Description

Comments makes code clear and allows users to understand easily. You can use both block style and inline comments in the code, but when you compile the LESS code, the single line comments will not appear in the CSS file.

Example

The below example demonstrates use of comments in the LESS file:
<html>
<head>
   <title>Less Comments</title>
   <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
   <h1>Example using Comments</h1>
   <p class="myclass">LESS enables customizable, manageable and reusable style sheet for web site.</p>
   <p class="myclass1">It allows reusing CSS code and writing LESS code with same semantics.</p>
</body>
</html>
Next, create file style.less.

style.less

/* It displays the
green color! */
.myclass{
color: green;
}
// It displays the blue color
.myclass1{
color: red;
}
You can compile the style.less file to style.css by using the following command:
lessc style.less style.css
Next execute the above command, it will create style.css file automatically with the below code:

style.css

/* It displays the
green color! */
.myclass {
  color: green;
}
.myclass1 {
  color: red;
}

Output

Let's carry out the following steps to see how above code works:
  • Save the above html code in comments.html file.
  • Open this HTML file in a browser, an output as below gets displayed.
Less Comments

No comments:

Post a Comment