CSS selector summary, css Selector

Source: Internet
Author: User

CSS selector summary, css Selector

Selector priority instance
ID picker 100
Class selector 10
Pseudo-class selector 10: link: visited: focus: hover: actived: lang
The UI element status pseudo Class E: enabled {} matches the available eElements in all user interfaces (form forms ).
E: disabled {} matches all the eElements that are unavailable in the form.
E: checked {} matches all the selected eElements in the form.
Structural pseudo-Class E: first-child {} matches the first Eelement in the parent Element
E: last-child {} matches the last Eelement in the parent Element
E: nth-child (n) {} matches the nth child element E
E: nth-last-child (n) {} matches the nth child element E
E: nth-of-type (n) {} matches the nth sibling Element E of the same type
E: nth-last-of-type (n) {} matches the nth sibling Element E in the same type
E: first-of-type {} matches the first Eelement In the sibling Element
E: only-child {} matches E that belongs to the unique child element of the parent element.
E: only-of-type {} matches E that belongs to the unique sibling element of the same type.
E: root {} is not commonly used to match the root element of a document. In HTML, the root element is always HTML
E: empty {} is not commonly used to match element E without any child elements (including text nodes ).
Negative pseudo-class p: not (s) {} matches all elements that do not match the simple selector s p
The target pseudo class is not commonly used.
Attribute selector 10
Simple attribute selector h1 [foo] {color: red ;}
Specific attribute value selector h1 [foo = "sun"] {color: red;} select the foo attribute value as all h1 elements of sun
Substring matching attribute selector h1 [foo * = "sun"] {color: red;} select all h1 elements whose values start with sun
H1 [foo ^ = "sun"] {color: red;} select all h1 elements whose values end with sun
H1 [foo $ = "sun"] {color: red;} select the foo attribute value that contains all the h1 elements of sun.
Element selector 1
Child element selector h1> span {color: red ;}
Adjacent sibling element selector h1 + h1 {font-size: 20px ;}
Sibling element selector h1 ~ H1 {font-size: 20px ;}
Pseudo element selector 1 p: first-letter {} set the first letter style of Section p
P: first-line {} set the first line style of Section p
P: before {} p: after {}
P: selection {} sets the style of the selected part.

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.