SELECT AN HTML ELEMENT USING A SPECIFIC ATTRIBUTE VALUE

You can use different attribute value operators to identify HTML tags with specific attribute values. You can use this in your CSS selector logic to match on attribute values that are complete words and stylize them accordingly:

element[attr='value'] { ... }element[attr~='value'] { ... }element[attr|='value'] { ... }

The = operator matches elements whose attribute value exactly matches value. For example, img[src='image. jpg'] will match only images of image.jpg. Note that other attribute values found in the selected HTML tag, such as alt='An image', will be ignored by the CSS selector.

The ~= operator matches elements whose attribute value contains a complete word that matches value. ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications 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.