Cascading Style Sheet (CSS)

Comments in Style Sheet

Adding comments to your code is always a good practice and we all must follow it religiously.

Be it a large application or a simple HTML webpage, the habit of adding comments wherever required, will definitely get you appreciation from your fellow developers as it makes understanding the purpose of any piece of code easier.


Comments in CSS

Comments, help better document our code so that it becomes easier to maintain and update, later on. CSS comments are similar to C programming comments. /* This is a comment */

Comments help other people and you, understand your code better, so it is recommended that you put comments in your code. In style sheet, we can add comments explaining where a particular style class is being used, so that whoever reads the comment gets an idea about the purpose of the style class/id.

The HTML comment syntax, <!— comment -->, does not apply to CSS and is ignored but you can use them to better organize your style blocks.

<style>

p { 
    /* font-size: xx-larger; */
    font-family: Serif; 
    /*
    color: red; 
    border: 5px;
    */
} 

</style>

Live Example →