Use of Web page technology to make CSS overall layout declaration

Source: Internet
Author: User
Tags define definition
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.



Related Article

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.