Introduction
Comments help you write notes inside your CSS code. They make it easier to understand and remember what your styles do.
Jump into concepts and practice - no test required
/* This is a comment in CSS *//* This comment explains the body styles */ body { background-color: lightblue; }
p {
color: red; /* This makes text red */
}/* This is a multi-line comment. It can span several lines. */ h1 { font-size: 2rem; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>CSS Comments Example</title> <style> /* Set background color for the whole page */ body { background-color: #f0f8ff; } /* Style for main heading */ h1 { color: #333; /* Use a friendly font */ font-family: Arial, sans-serif; } /* Paragraph text color */ p { color: #666; } </style> </head> <body> <h1>Welcome to CSS Comments</h1> <p>This page shows how comments work in CSS.</p> </body> </html>
p {
color: blue; /* This is blue text */
/* color: red; */
}body {
color: green; /* Set text color
background: white;
}