Skip to Content
CSS Cookbook, 3rd Edition
book

CSS Cookbook, 3rd Edition

by Christopher Schmitt
December 2009
Intermediate to advanced
728 pages
15h 59m
English
O'Reilly Media, Inc.
Content preview from CSS Cookbook, 3rd Edition

Appendix D. CSS3 Selectors and Pseudo-Classes

Although CSS3 is still being worked on as this book is being written, some browser vendors are starting to support properties from the unfinished specification. This appendix provides a listing of the new CSS3 selectors for your reference.

To get a solid idea of what tools you have at your disposal to apply styles to a document, consult Appendix C (which covers CSS 2.1 selectors) in conjunction with this listing.

Table D-1 describes the new CSS3 selector, the general sibling selector.

Note

In the “Generic pattern” column of Table D-1, the values C, R, and S take the place of type selectors.

Table D-1. New CSS3 selector
SelectorGeneric patternDescriptionSample

General sibling combinator

C \~ R

Matches any R element that is preceded by a C element

#content \~ img + +{ padding: 2px; border 2px solid black; }

Table D-2 contains a list of new attribute selectors. These allow greater control when selecting elements in a document based on an attribute’s value or even a small portion of that value.

Table D-2. CSS3 attribute selectors
SelectorGeneric patternDescriptionSample

Attribute selector

C\[attribute\^="valueR"\]

Selects any C element that contains the attribute that begins with the value of valueR

img\[alt\^="mugshot"\] { width: 100px; }

Attribute selector

C\[attribute$="valueR"\]

Selects any C element that contains the attribute whose value exactly matches valueR

img\[alt$="photo"\] { border: 10px solid red; }

Attribute selector

C\[attribute\*="valueR"\]

Selects ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

CSS Master, 3rd Edition

CSS Master, 3rd Edition

Tiffany B Brown
CSS in Depth

CSS in Depth

Keith Grant
Mastering CSS

Mastering CSS

Rich Finelli

Publisher Resources

ISBN: 9781449377250Errata Page