1. About comments
When creating an xhtml CSS website, comments in CSS are very important. When creating CSS styles, you should maintain the habit of commenting casually. Generally, I am used to using the format of "/* Comment content */" to write comments, because in editors with highlighting functions such as EditPlus, the commonly used "/********" in C language is used. Comments such as *******/" are meaningless, and there is no need to fill in a lot of meaningless content as separation. Documents with comments serve as the original CSS documents of the website. When publishing the website, you can use a CSS compression tool to compress the CSS and remove comments from the output CSS to improve file transfer efficiency.
2. About naming
When naming CSS files, I prefer to use semantically correct English names or abbreviations. I may use partial pinyin names for unusual parts. In addition, in some dependent classes, I may use a name similar to "list_banner", that is, the parent element name plus "_" plus the element name.
About naming, it can be negotiated according to the habits of the team designers. But it’s best to add a comment after the name so that you can generate documentation for future reference.
3. About inheritance
In CSS, inheritance must be made good use of. For example, in two nested divs, the parent element defines the background-color attribute as black. If the background of the child elements is also black, there is no need to repeat the definition. Making good use of CSS inheritance can make your code more efficient and streamlined.
4. About the hierarchy of CSS definitions
When defining classes in CSS, it is recommended to use a hierarchical way to describe statements.
Example structure: