Comments in CSS are used to add instructions and do not affect the style. They start with / comment text / syntax and end with /. There are two types of CSS comments: single-line (//comment text) and multi-line (/comment text */). Use comments to explain the purpose of the code, record changes, provide more information, and disable blocks of code. Best practices include keeping it short and clear, reviewing it regularly, adding whitespace, and formatting multi-line comments.
How to write comments in CSS
In CSS, comments are used to add instructions or remarks to the code, and It will not affect the style of the page. Comments are useful when debugging, documenting code, and collaborating with other developers.
Syntax for CSS comments
CSS comments use the following syntax:
<code class="css">/* 注释文本 */</code>
The start of the comment is represented by the /
character pair, The end of a comment is indicated by the */
character pair.
Comment types
There are two types of comments in CSS:
//
followed by the comment text. /*
followed by the comment text, ending with */
. Using Comments
Common reasons for using comments in CSS include:
Best Practices for Comments
The above is the detailed content of How to write comments in css. For more information, please follow other related articles on the PHP Chinese website!