We should develop good coding habits, CSS overall layout 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 statement is to summarize the objectives as a whole, declaring some identical or substantially identical attributes and values, so as not to be defined separately in each tag in the subsequent code. If you have different attributes and values, you can redefine them later.
First, the general layout declaration of the wildcard.
* {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 we declare the margin and padding to zero, the font size is 0.8em. The properties and values for this claim are applied to the elements in the page. Unless the values of margin, padding, font-size are defined again in later code, they are displayed as this definition.
Second, the label of the overall statement
Body {background: #fff; font-family:courier, "Courier New", monospace;} or P {background: #fff; Font-family:courier, "Co Urier New ", monospace; }
This type of declaration is for some XHTML tags. If there is no special definition, this statement will apply. We define the background color and font of the body. So the element within the body applies to it unless it is defined again. The principle of the definition of paragraph p is the same.
Third, group-style 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 case. We do not necessarily do this in practice, perhaps some of the XHTML elements of class or ID have the same attributes, we can all group up code. There are different places that can be redefined individually. For example, this http://www.52css.com/article.asp?id=392 instance is designed in a refreshing CSS form with small icons. We have used this type of declaration.
The above is the CSS overall layout declaration of some use of skills _ experience Exchange content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!