CodesCompiler
🔍
HTMLCSSJavaScriptPythonSQLPHPSEOPostsBooksKids About Contact 🚀 Get Started Free

CSS - Comments

CSS - Comments

In CSS, comments are useful in adding explanatory notes or annotations within your stylesheet that are not interpreted as styling instructions by the web browser.

Syntax

CSS CODE
/* This is a comment */
p {
  color: red; /* Set text color to red */
}

CSS comments are intended for the benefit of developers and are ignored by the browser when rendering a web page. They are useful in documentation, debugging, etc.

Types of CSS Comments

In CSS, there are two main ways to create comments:

  • Single-line Comments: Single-line comments are created using /* to start the comment and */ to end it.

  • Multi-line Comments: Multi-line comments allow you to add comments that span multiple lines. They are also enclosed within /* and */ .

CSS CODE
/* Single line Comment */

/*
Comment
which stretches
over multiple
lines
*/

HTML And CSS comments

In HTML tutorial we learned that, a command in HTML is defined between <!-- and --> symbols.

Syntax

Preview

Example

Here is an example showing html comment and CSS comment format:

Preview