Home>Article>Web Front-end> How to add comments to css?
CSS comments are used for annotations. We often use CSS annotations to make special comments on CSS code or layout CSS styles. There are also conditional comments for functional use.
Basic syntax of CSS comments:
/* 注解注释内容 */
Description: It starts with "slash asterisk (/*)" and ends with "asterisk slash (*/)". The annotation content is placed between "/*" and "*/". It should be noted that the comment characters are all English half-width lowercase; and the "*" symbol should not be placed next to the comment content, and at least one space must be left empty.
Example:
/* css注释实例 */ /* body定义 */ body{ text-align:center; margin:0 auto;} /* 头部css定义 */ #header{ width:960px; height:120px;}
If we encounter a place that needs special explanation when writing CSS, we can use CSS annotations to annotate. Comments are helpful for others to read and understand the developed CSS code. Proper use of comments and as few comments as possible are beneficial to compatibility and file size reduction.
The above is the detailed content of How to add comments to css?. For more information, please follow other related articles on the PHP Chinese website!