CSS – Comment and Example


CSS Comments

Comments are the useful source to define our code or to make a coder understand the code applied. This may help us to edit our code in future. Comments are not displayed by browsers.

CSS comments start with /* and end with */.

Why Are Comments Required?

Comments are required to make code understandable, we don’t have to think we are not only the coder, programmer.
If another engineer or developer check any part of code then S/He should know what is that code and why that code exists. So it’s better to put comments while doing coding.

CSS Example

The declaration part must end with a semicolon, and curly braces after each declaration.
background-color: 0f0;

/* header level one background color is green – 0f0 – for Single Line Comment */
text-align: left;
/* text align is always left
for all header level one
-for Multi Line Comment */

Comments are always ignored by the browser, the browser won’t display the comments. It is only used to make code readable.

Unfortunately, CSS doesn’t have any easy way to add the single line comment, Like in JavaScript you can do like this.

JavaScript Example

//This is the single line comment in JavaScript


Please enter your comment!
Please enter your name here