2016年10月17日月曜日

CSS Selectors and Combinators

Pattern

Meaning

CSS3?

Selector Type

*

any element

Universal selector

E

an element of type E

Type selector

E[foo]

an E element with a "foo" attribute

Attribute selector

E[foo="bar"]

an E element whose "foo" attribute value is exactly equal to "bar" (quotes are optional)

Attribute selector

E[foo~="bar"]

an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar" (quotes are optional)

Attribute selector

E[foo^="bar"]

an E element whose "foo" attribute value begins with "bar" (quotes are optional)

Y

Attribute selector

E[foo$="bar"]

an E element whose "foo" attribute value ends with "bar" (quotes are optional)

Y

Attribute selector

E[foo*="bar"]

an E element whose "foo" attribute value contains "bar" somewhere within it (quotes are optional)

Y

Attribute selector

E[foo|="en"]

an E element whose "foo" attribute has a hyphen-separated list of values beginning (from the left) with "en" (quotes are optional)

Attribute selector

E:root

an E element, root of the document

Y

Structural pseudo-class

E:nth-child(n)

an E element, the nth child of its parent

Y

Structural pseudo-class

E:nth-last-child(n)

an E element, the nth child of its parent, counting from the last one

Y

Structural pseudo-class

E:nth-of-type(n)

an E element, the nth sibling of its type

Y

Structural pseudo-class

E:nth-last-of-type(n)

an E element, the nth sibling of its type, counting from the last one

Y

Structural pseudo-class

E:first-child

an E element, first child of its parent

Structural pseudo-class

E:last-child

an E element, last child of its parent

Y

Structural pseudo-class

E:first-of-type

an E element, first sibling of its type

Y

Structural pseudo-class

E:last-of-type

an E element, last sibling of its type

Y

Structural pseudo-class

E:only-child

an E element, only child of its parent

Y

Structural pseudo-class

E:only-of-type

an E element, only sibling of its type

Y

Structural pseudo-class

E:empty

an E element that has no children (including text nodes)

Y

Structural pseudo-class

E:link,E:visited

an E element being the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited)

Link pseudo-classes

E:focus,E:hover,E:active

an E element during certain user actions

User action pseudo-classes

E:target

an E element being the target of the referring URI

Y

Target pseudo-class

E:lang(fr)

an element of type E in language "fr"

:lang()pseudo-class

E:enabled,E:disabled

a user interface element E that is enabled or disabled

Y

UI element states pseudo-classes

E:checked

a user interface element E that is checked (for instance a radio button or checkbox)

Y

UI element states pseudo-classes

E::first-line

the first formatted line of an E element

::first-linepseudo-element

E::first-letter

the first formatted letter of an E element

::first-letterpseudo-element

E::before

generated content before an E element

::beforepseudo-element

E::after

generated content after an E element

::afterpseudo-element

E.warning

an E element that has a class of "warning"

Class selector

E#myid

an E element with an ID equal to "myid"

ID selector

E:not(s)

an E element that does not match simple selector s (for example,input:not(.warning))

Y

Negation pseudo-class

E F

an F element descendant of an E element

Descendant combinator

E > F

an F element child of an E element

Child combinator

E + F

an F element immediately preceded by an E element

Adjacent sibling combinator

E ~ F

an F element preceded by an E element

Y

General sibling combinator

Table B.2 is derived from the CSS3 selector module at www.w3.org/TR/css3-selectors/ and is copyright © World Wide Web Consortium (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.

 

0 件のコメント:

コメントを投稿