CSS / CSS3 Styling2 min read

CSS Comments

In this tutorial we will learn how to put comments in your CSS style sheet

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 โ†’



INTERACTIVE SIMULATION CHALLENGE+250 XP
Workbench Verification

Ready to test "CSS Comments" in production?

See how CSS / CSS3 Styling algorithms and server loops perform under 100k req/s traffic spikes.

Simulator: SysDesign Ops Simulator