Comments in CSS
? Comments in CSS
Comments let you add notes or explanations inside your CSS code — they are ignored by browsers and don’t affect how styles work.
Syntax of CSS Comments
/* This is a comment */Starts with
/*Ends with
*/Can span multiple lines
Examples
Single line comment:
/* This sets the main color */body { background-color: #f0f0f0;}Multi-line comment:
/* This is a multi-line comment. You can write as much as you want here.*/h1 { color: navy;}Why Use Comments?
Explain complex code or intentions.
Temporarily disable CSS rules without deleting them.
Organize code into sections.
Important Notes
Nested comments are NOT allowed in CSS.
This is invalid:/* Outer comment /* Inner comment */*/Comments can appear anywhere in your CSS file, even between selectors or properties.
If you want, I can show you examples of well-commented CSS files or help you organize your styles with comments!