Chapter 8. Advanced Selectors

<feature><title>What You’ll Learn in This Hour:</title>
  • How to create CSS rules that select only those tags that have a specific attribute

  • How to create rules based on the values of those attributes

  • How to create rules that select direct children of another element and why you’d want to do that

  • How to select an element that directly follows another element

</feature>

Attribute Selectors

An attribute selector tests for the existence, and possibly the values, of any specific HTML attributes set on an element. You’d use an attribute selector if you wanted all elements with a certain attribute to be styled a certain way. For example, noshade is an HTML attribute for the <hr> tag; it means that there shouldn’t be any shading ...

Get Sams Teach Yourself CSS 24 in Hours 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.