O'Reilly logo

Learning Web Design, 5th Edition by Jennifer Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C. CSS Selectors, Levels 3 and 4

C

CSS Selectors, Levels 3 and 4

The following table lists the selectors in the Selectors Level 4 Editor’s Draft (, December 2017).

Note that selectors marked “(Level 4)” are new and may not yet be implemented by browsers. Check and be sure to test well if you use them. All other selectors are part of CSS3 and are generally well supported.

Selector

Type of selector

Description

Simple selectors and combinators

*

Universal selector

Matches any element.

A

Type selector

Matches the name of an element.

A, B

Compound selector

Matches elements A and B.

A B

Descendant combinator

Matches element B only if it is a descendant of element A.

A>B

Child combinator

Matches any element B that is a child of element A.

A+B

Next-sibling combinator

Matches any element B that immediately follows any element A, where A and B share the same parent.

A~B

Subsequent-sibling combinator

Matches any element B that is preceded by A, where A and B share the same parent.

Class and ID selectors

.classname A.classname

Class selector

Matches the value of the class attribute in all elements or in a specified element.

#idname A#idname

ID selector

Matches the value of the id attribute in an element.

Attribute selectors

A[att]

Simple attribute selector

Matches any element A that has the given attribute defined, whatever its value. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required