CSS Comments

A comment in CSS is a block of code that is not executed by the browser. Comments are completely ignored by the browser and do not play any role in the final output.

Comments are used for explanation purposes only which can later help other programmers to understand the pre-existing block of code.

A comment in CSS starts with a /* symbol and ends with */ symbol. Refer to the example below:

Example:

/* This is a comment. */
p{
    color:blue;
}

A comment can also be placed in the same line as the executable code. Such comments are called inline comments. These comments are used to provide some additional information about a particular line of code in which it is placed. See the example below:

Example:

p{
    color: blue; /* It sets the text color to blue */
}

A comment in CSS can also span multiple lines. Such comments are called multi line comments. Refer to the example below:

Example:

/* This is
a multi-line
comment */
p{
   color: blue;
}

Author

  • Manoj Kumar

    Hi, My name is Manoj Kumar. I am a full-stack developer with a passion for creating robust and efficient web applications. I have hands-on experience with a diverse set of technologies, including but not limited to HTML, CSS, JavaScript, TypeScript, Angular, Node.js, Express, React, and MongoDB.

Leave a Comment