CSS Comments
Part of the Styling with CSS section of Coddy's HTML journey — lesson 3 of 76.
Comments are notes within the code that do not get executed, they are just for making the code more readable and maintainable.
In CSS, comments are written between /* and */ tags. Anything placed between these tags will be treated as a comment and will not affect the styling of the page.
Here's how you can write a comment in CSS:
/* This is a comment */
p {
color: blue; /* This sets the text color to blue */
}In this example, "This is a comment" and "This sets the text color to blue" will not affect the code. Comments are useful for explaining complex code, leaving notes for yourself or other developers, and temporarily disabling code.
Cheat sheet
CSS comments are written between /* and */ tags and do not get executed:
/* This is a comment */
p {
color: blue; /* This sets the text color to blue */
}Comments are useful for explaining code, leaving notes, and temporarily disabling code.
Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Styling with CSS
5 Colors and Backgrounds
Background ColorHEX ColorsRGB ColorsTransparency with RGBARecap Challenge #1