Revisit the document structure of CSS

Source: Internet
Author: User

Source: http://limits.cnblogs.com

Let's take a look at some basic HTML pages

1 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 2 

Shown below:

Document structure such as:

Particularity:

The weights of the different rules are specified, and the higher weights are preferred when multiple rules are available for the same element.

h1 {color:red;} /* Special =1*/p Em{color:blue;} /* Special =2*/.divclass{color:yellow;} /* Special =10*/p.note Em.dark{color:gray;} /* Special =22*/#id {color:black;} /* Special =100*/

Use !important to identify important rules, such as:p{color:red!important;} , the color:red will have the highest weight, because the rules for declaring this will be higher than the definition of the local style of the visitor ( that is , the definition within the P tag ), so ! Important should be used with caution.

Element classification:

    1. Block-level elements (Display:block): Each block-level element starts with a new line, and the subsequent element also requires another line to start the title, paragraph, table, layer,body, etc. are block-level elements;
    2. Inline elements (display:inline): inline elementsdo not need to be displayed on new lines, and also do not force subsequent elements to wrap, such as A,em,span, etc. are inline elements, and inline elements can be child elements of any other element;
    3. List item (Display:list-item): Only the Li element is the default of this type, and this element behaves like a list;
    4. Hidden element (display:none): When an element is set to Display:none , the browser ignores the element completely, and the element will not be displayed or occupy a position.

Revisit the document structure of CSS

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.