Selecting Elements Based on Attributes
You can also apply formatting to those elements that have a given attribute or attribute value.
Figure 9.35. In this code, only the two inner div elements have class attributes.
To select elements to format based on their attributes:
1. | If desired, type element, where element is the selector for the element whose attributes are in question.
|
2. | Type [attribute, where attribute is the name of the attribute that an element must have to be selected.
|
3. | If desired, type ="value" if you want to specify the value that the attribute must have for its element to be selected.
Or, if desired, type ~="value", to ... |
Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide 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.