1. Code naming standardization, do not use desultorily named, do know meaning by name

If you name too simple using letters, such as “A, B, C”, for a long time, it is easy to forget which part of the plate the name represents, which is not conducive to later maintenance

2. Code abbreviations

Abbreviations can speed up your writing and reduce the amount of code you write. CSS has a number of properties that can be abbreviated, including margin, padding, border, font, background, etc

3. Take advantage of the inheritance of the CSS

CSS follows parent-child inheritance, which reduces excessive naming, such as #box li{color:red; } this changes the color of the li element after id #box

4. Use multiple selectors

If multiple elements have the same style, they can be written together:

h1{float:left; color:red}

h2{float:left; color:red}

h3{float:left; color:red}

Written for h1, h2, h3 {float: left; color:red}

5. Comments

Code annotation is very important, you can annotate different sections separately, easy to find next time

6. Refer to external stylesheets

CSS files written externally are easier to maintain, and CSS files can be cached in the browser. Built in documents are re-downloaded with documents on each request. So, in practice, there is no need to build code into an HTML document

7. The upper and lower structure of the CSS

The CSS code written in the following section is read preferentially. Therefore, pay attention to the naming and structure of the CSS code to prevent the CSS style written in the following section from affecting the CSS code written in the preceding section

—————— personal understanding, if there is a wrong, welcome to correct ——————