Css selector, css

Source: Internet
Author: User

Css selector, css
Introduction to common Selector


The wildcard character specifies all types of single objects in the Document Object Model (DOM.

* {CssCode rules}, where*Indicates all types, including body, div, and td.

The Type selector uses the Document Object Model (DOM) as the selector. That is, you can select an html tag as an object and set style rules.

P {

}

Div {

}

The sub-Layer Control of a container layer is that other objects with the same name are not affected by this rule. objects with the same name must be selected in sequence, from large to small, that is, from the container layer to the child layer.

E1 E2

{

}

E1It refers to the parent layer object, and E2 refers to the small layer or child layer object, that is, the E1 object contains the E2 object

Eg:

Table td

 

{

}

Td p

{

}

Common Layout selector:

IDThe identifier indicates that the unique identifier ID is used as the identifier in the DOM. The ID is preceded by "#" and followed by the ID name, note that the ID Identifier cannot appear twice or more than twice in the style. If it appears, the first occurrence of the identifier will prevail, and others will be ignored.

The class selector is also called the class selector, indicating that a class can be used multiple times in the document.

Start with ".", followed by the class name

Note: The class selector and the type selector are different. The type refers to the tag in html.

The Group selector sets the same style for multiple tags. In different types, it indicates the same style.Separate the delimiters with commas (,) and group the delimiters.

Html, Body

{

}

 

The following table summarizes the above content.

Selector Expression Example Description
Wildcard character *{CssCode rules} * {CssCode rules} *Indicates all types, including body, div, and td.
Type Selector Take the Document Object Model (DOM) as the selector

P {}

Div {}

Select an html tag as an object and set style rules
Include Selector  

E1 E2

{

 }

E1It refers to the parent layer object, and E2 refers to the small layer or child layer object, that is, the E1 object contains the E2 object
IDSelector Start,Followed by ID    
Class Selector Start with ".", followed by the class name    

Group Selector

 Separate the delimiters with commas (,) and group the delimiters.  

Html, Body

{

}

 Set the same style for multiple tags. In different types, the same style is displayed.

 

 

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.