Comments are used to explain the code, and may help when you edit the source code at a later date.
Comments are ignored by browsers.
A CSS comment is placed inside the
/* This is a single-line comment */ p { color: red; }
You can add comments wherever you want in the code:
p { color: red; /* Set text color to red */ }
Even in the middle of a code line:
p { color: /*red*/blue; }
Comments can also span multiple lines:
/* This is a multi-line comment */ p { color: red; }
In HTML, all comments are technically multi-line.
In CSS, single-line comments start with // and end at the end of the line, while multi-line comments start with /* and end with */
CSS comments work similarly to HTML comments.
The difference between them is that CSS comments are designated with the symbols /* ... */, whereas HTML comments are enclosed in
In CSS, we can add comments to explain or organize different sections of your stylesheet. Doing so might seem like an extraneous step in the coding process, but comments can be extremely helpful when debugging or redesigning your website.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3