Related Tags

How to add comments in CSS

css
comments
singe line comment
multi line comment
/*

It is a common practice to add comments in the code to enhance readability and add helpful notes alongside the code. Like most languages, CSS allows the users to add comments in the stylesheet.

Comments in CSS can be added by using the /* tag, which is then closed off by using */.

Note: Code that is commented out is not used to style the page.

This technique can be used to add both single and multi-line comments.

1. Single line comments

Single line comments can be added as follows:

/* This is a SINGLE LINE COMMENT */

Note: Users may observe that the // tag can be used to add single line comments. However, this is not the standard practice in CSS and therefore should not be used.

2. Multi-line comments

Multi-line comments can be added using the same /* tag:

/* This is a 
MULTI LINE COMMENT 
in CSS */

Example

Let’s add comments to a functioning piece of code and see how it works:

  • CSS
RELATED COURSES
View all Courses
Related Courses
Related Courses
View all Courses

Keep Exploring