Commenting your code will help you and others to better understand the code. If you or someone else have to change your code, maybe after a long period since the code was written, the comments should clarify what a block of code does and why it was added in the first place.
In this recipe, you will need a randomly chosen Less file without a comment. If you don't have such a file, you can create one yourself.
Open your Less file.
Then, start adding comments.
Both Less and CSS allow you to use block-level comments that start with
/*
and end with*/
. The following code will show you an example of a block-level comment:/* * Example code for Less Cookbook * copyright 2014 by Bass Jobsen */
In contrast to CSS, Less allows single-line comments. A single-line comment starts with
//
, as shown in the following example code:@menuColor: red; //sets the background color for the menu