CSS Comments

Comments

The comments are just used to specify what we are doing in some particular line. This also helps us understand the code better. The comments are ignored by the browser.

So, when you are writing the CSS rules, you can write the description of the rules inside the comments. As stated earlier, the comments are straightaway ignored by the browser.

The CSS comment is supposed to be placed inside the <style> element(or in the CSS file), and is given as –

Comments

You can write the comment anywhere in the CSS code, and this is a multiline comment so you can also write some broad description about the styling you are doing. Also, if there are some CSS rules/properties that you don’t want to apply, but still want them to be there, you can just comment on them since anything in the comment is just ignored by the browser, even if it is some CSS rules.

Have a look at the below example –

If you try to write this code and open the file in the browser, you can find that the comments are not there anyways, and the text-align property was also ignored since it is a comment.

We can use the comments as and when required. Now we know that the comments are used for different purposes.