ADVERTISEMENTS

How to write comments in CSS

In CSS, comments are used to describe or explain parts of your style sheet and are ignored by the browser when the style sheet is loaded. It is best practice to use comments to explain what a certain block of code is doing, so that it is easier to understand and maintain the code base. Comments are also useful for temporarily disabling a section of code without having to delete it. Comments can be placed anywhere in the style sheet, but it's usually best to place them at the beginning or end of a block of code.

The following example will explain about comments in css with code snippet.

/* Single line CSS comment */
/* Example of a
   CSS multi-line comment */
body.main{
    font-family: Ssans-serif;
}
p {
    color: #000;
}

 

Supported Browsers:
  • Internet Explorer
  • Mozilla Firefox
  • Google Chrome
  • Opera
  • Safari

CSS is a styling language used to control the presentation of HTML webpages. You can learn CSS from our CSS Tutorials and CSS Examples

ADVERTISEMENTS