Selecting Elements Based on Attributes

You can also apply formatting to those elements that have a given attribute or attribute value.

To select elements to format based on their attributes

1. 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.

Image For demonstration purposes, I’ve changed the class value on the second section element from project to work.

<article class="about">     <h1>Antoni Gaudí</h1>     <p>Many tourists are drawn to Barcelona to see Antoni Gaudí's incredible architecture.</p>     <p>Barcelona ...

Get HTML5 and CSS3: Visual QuickStart Guide, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.