CSS selector's base selector

Category foundation selector

  1. id selector: selecting a specific element of id attribute value

  2. Selector element: selecting elements with the same label name

  3. Class selection: Select an element having the same class attribute values.

 

id selector

id selector, the corresponding tag is selected according to the value of the id attribute tag.

format:

#id values { 
    attribute name 1: 1 attribute value; 
    property name 2: attribute value 2; 
    ... 
}

Example: p defines two labels, and different tag id attribute value, then the contents of the tag is defined by p how to display CSS.

Google browser to open, view the results:

Element selector

The selector element are selected in accordance with the corresponding tag name tags.

format:

Name tags { 
    attribute name 1: 1 attribute value; 
    property name 2: attribute value 2; 
    ... 
}

Example: div defines two labels, label p is defined by the contents selecting how to display elements.

Google browser to open, view the results:

Note: id selector element is higher than the priority selector

 

Class selector

Class selector, the corresponding tag is selected according to the class attribute value tag.

format:

.class values { 
    attribute name 1: 1 attribute value; 
    property name 2: attribute value 2; 
    ... 
}

Example: p defines two labels, and different class attribute value of the tag, then the contents of CSS defines how to display labels p.

Google browser to open, view the results:

Note: Select class selector priority over the selector element

 

          

Guess you like

Origin www.cnblogs.com/liyihua/p/12364940.html