CSS attribute selector
Attribute selectors aren't common, but they have some powerful use cases. They allow you to target elements that have a particular attribute or attribute value.
Attribute selectors are enclosed in square brackets ([...]
). For example, to style all elements with a title
attribute, we'd use the selector [title]
. We can also target elements with specific titles. In that case, the code would look like [title="Important"]
.