css| Web page
We should develop good coding habits, the overall layout of the CSS statement for our code simplification, improve operational efficiency provides a way. We enumerate the more commonly used forms and add explanations. The purpose of the overall layout declaration is to generalize the goal as a whole, declaring some identical or essentially identical properties and values, so that each label in the following code needs to be defined separately. If you have different properties and values, you can redefine them later.
First, the overall layout of the distribution statement.
* {
margin:0;
padding:0;
Font-size:0.8em;
...
}
This type of declaration is for the entire page. You can set properties that are common to page elements. Without having to declare each element individually. The above code states that the margins and padding are zero, and the font size is 0.8em. The attributes and values for this declaration are applied to the elements in the page. Unless you define the values of margin, padding, and font-size again in the following code, this is the definition to display.
Second, the label-type overall statement
Body {
Background: #fff;
Font-family:courier, "Courier New", monospace;
}
Or
p {
Background: #fff;
Font-family:courier, "Courier New", monospace;
}
This type of declaration is for some XHTML tags. If there is no specific definition, this declaration will apply. We define the background color and font of the body. So the elements within the body apply to it, unless defined again. The principle of defining paragraph p is the same.
Third, group-type overall statement
h1,h2,h3 {color: #00f; font-weight:100;}
This type of declaration represents the text color of the h1,h2,h3 and the font bold. In practice, it is not necessarily the case that some of the XHTML elements of class or ID have the same attributes, and we can all group together to encode. There are a few different places that can be redefined separately.