untitled

(John Hannent) #1

Selectors Using Attributes .........................................................................


Warning: This trick also doesn’t work in Internet Explorer. Attribute selectors
allow you to define a style that applies only to places where a particular
HTML attribute exists as part of an element. Here’s an illustration. Say you
wanted to apply a border around only those paragraphs that had an align-
right attribute:

<p align=”right”>

Or

<p align=”right” color=”blue”>

You would then create a style like this, using brackets:

p[align=’right’] {border: 3px solid gray;}

and hope for the best. However, this doesn’t work in Internet Explorer, so you
can ignore it for now (and perhaps forever). For more on this particular kind
of specialized selector, see Chapter 3.

264 Part IV: Advanced CSS Techniques

Free download pdf