Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

B. CSS3 Selectors

Appendix B. CSS3 Selectors

Selector

Type of selector

Description

Simple selectors and combinators

*

Universal selector

Matches any element.

* {font-family: serif;}

A

Type selector

Matches the name of an element.

div {font-style: italic;}

A, B

Grouped selectors

Matches elements A and B.

h1, h2, h3 {color: blue;}

A B

Descendant selector

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

blockquote em {color: red;}

A>B

Child selector

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

div.main>p {line-height: 1.5;}

A+B

Adjacent sibling selector

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

p+ul {margin-top: 0;}

A~B

General sibling selector

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


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint