CSS overall layout declaration of some use tips _ experience Exchange

Source: Internet
Author: User
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)!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.