Current location - Quotes Website - Signature design - What are the css selectors? Priority order of various selectors
What are the css selectors? Priority order of various selectors
The CSS selector is as follows:

1.

Label name selector

discrepancy

{

Color: red; }

/is the css style of each tagname in the page.

2. Category Selector

. divClass

{color: red; }

/is the class of each label defined.

Css style in

3.ID selector

#myDiv

{color: red; }

/is the id of the tag in the page.

4. Descendant Selector (Descendant Selector of Class Selector)

. divClass

span

{

Color: red; }

/That is, multiple selectors are separated by commas.

Name it to find the exact label

5. Group selector

div,span,img

{Color: red}

/That is, labels with the same style are displayed in groups.

Priority of selector

1. The highest priority is

(Set the style directly in the label, assuming the level is 1000)

2. The second priority is (ID selector

, assuming the grade is 100)

# my div { color:Red; }

3. The second priority is (class selector, assuming the level is 10).

. DivClass {color: red; }

4. The last point is

(Label Selector, assuming the level is

1)

Div {color: red; }

5. The priority of the descendant selector can be calculated.

take for example

. divClass

span

{

Color: red; }

The priority is:10+1=11.