If there is no fixed beginning when writing css, just write the select statement.
1. Of course, there is also the statement of @charset "utf-8"
This statement tells the browser [my CSS file is UTF-8 encoded], but in fact this file does not need to be UTF-8 encoded, so this statement can deceive the browser.
But practice shows that chrome will have incompatibility bugs, so you can try writing like this:
@charset="UTF-8";
@charset="utf- 8";
2. Conventional approach (default style elimination)
*{margin:0; padding:0}/*Global style: inside and outside The margin is 0*/
li{list-style:none}/*Eliminate the small dot in front of the li tag*/
a{text-decoration:none}/*Eliminate a Tag underline*/
img{border:none}/*Eliminate the border of the picture, ps: because when the picture is wrapped by the a label, a border will be automatically added to the picture, just like the text of a package will be added to the text Same as underlining*/
body{width:100%; max-width:640px; margin:0 auto; overflow:hidden}
This cannot be said to be a standard beginning, but in The experience accumulated when writing styles is to eliminate the default styles that we generally do not use in the page at the beginning of the CSS, so as to prevent us from repeatedly eliminating the styles in subsequent writing, wasting work time and reducing work efficiency.
The above is the detailed content of How to write the beginning of css file. For more information, please follow other related articles on the PHP Chinese website!