Appendix D. CSS Selectors Reference

Obviously, browser support for CSS selectors varies, so testing is critical. What follows is an overview of just some of the available CSS selectors. These and more can be found in the CSS specifications, as described at www.w3.org/TR/REC-CSS2/selector.html.

Selectors

E

Type or Element selector

Matches any E element

<LINELENGTH>50</LINELENGTH>
p {color:red;}
<p>This text is red</p>

E.warn

Class selector

Matches element E with class of warn

<LINELENGTH>50</LINELENGTH>
div.warn {color:red;}
<div class="warn">This is red</div>

Classes can be used by themselves to apply to any element:

<LINELENGTH>50</LINELENGTH>
.warn {color:red;}
<div class="warn">This is red</div>
<p class="warn">So is this</p>

#myid

ID selector

Matches any E ...

Get Adapting to Web Standards: CSS and Ajax for Big Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.