CSS Comments


CSS comments let you leave notes, explanations, or reminders inside your stylesheet. They never show up on the webpage, because the browser politely ignores them. Comments help keep your CSS organized and understandable.


Single-Line Comment

Syntax:

/* This is a single-line comment */

Example:

p { color: blue; }
/* This text explains what the style above does */

Output:

This paragraph is blue.



Multi-Line Comment

You can write comments across multiple lines using the same syntax.

Syntax:

/*
This is a multi-line comment.
You can write as many lines as needed here.
*/

Example:

/*
This CSS block changes the heading color.
Just a friendly explanation.
*/
h2 { color: purple; }

Output:

Welcome to ByteAcademy



Comments to Disable Code

You can temporarily disable CSS rules by commenting them out. This is helpful when debugging layouts or testing styles.

Example:

/* p { font-size: 30px; } */
p { font-size: 16px; }

Output:

This paragraph uses the active CSS rule.


HTML Logo