CSS comments

CSS Comments

CSS comments are not displayed on the screen. It helps the developers to understand the source code & it applies inside a CSS file or style element.

Important fact regarding CSS Comment :
  • CSS comment is not displayed on the screen. It helps to understand the source code by the developers.
  • It applies inside any CSS file or inside <style>element.
  • It starts with /* and ends with */.
  • Multi Line Comments-Write more than one comment inside /* and */.

Note:The CSS comment statement does not display on the screen & it is useful for a screen reader.

Single Line Comment

Write a single line inside /* and */ to make a single-line comment.

Source Code

Try it now

Code Explanation

Note:The CSS single line comment statement is written inside / * Your CSS Comment Statement */ statement.

Multi Line Comment

Write more than one line inside /* and */ to make multi-line comments.

General syntax for writing multi line comment:

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Follow the above mention steps to create single and multi-line comments.

Difference Between HTML & CSS Comment

  • HTML comment starts with <!-- and end with -->
  • CSS comment starts with /* and end with */

Example

Source Code

Try it now

Code Explanation

Note:Please keep in mind that HTML and CSS comments are useful for screen readers as well as other developers.

Online Test / Quiz