Latest Blog Posts at


How to Comment CSS

Placing comments in a CSS file or code block can serve multiple purposes.
  • CSS comments can be used to explain the concepts of a block of CSS.
  • CSS comments can be essential during the development of a site to turn on/off specific elemental stylings.
  • CSS comments can control a temporary change into a site that may be reverted at a later date.
  • CSS comments can be crucial to organizing the logical structure of a CSS stylesheet.
For whatever the reason used to comment CSS, commenting CSS code is a simple way to not allow the commented code or text to execute when browsers load a stylesheet upon a visit to the site.

Different methods of commenting CSS

Both single and block comments in CSS b begin with a /* (forward slash + asterisk) and end with a */ (asterisk + forward slash). Several examples of commented CSS using both the single and block comments:
/* Single line comment */ .css-class { font-size: 2em; margin: 15px 4px; text-align:center; } /* Sometimes you might want to extend your comments into more of a block. */
  There are no restrictions as to the number of CSS comments that…

Read more