Jawad Asghar Ali
Jawad Asghar Ali

Reputation: 45

Grouping in CSS attribute selectors

Are these equivalent:-

selector[attr1="val1"] [attr2="val2"] {
  property: value;
}

Select a {selector} which has a attribute called [attr1] that has the exact value of "val1", AND also the same {selector} which has a attribute called [attr2] that has the exact value of "val2". Since the logical operator is "AND", any one condition being wrong will make the selector fail.

selector[attr1="val1"], selector[attr2="val2"] {
 property: value;
}

This one uses grouping. Can I assume the same for the later as I did for the former?

Upvotes: 1

Views: 267

Answers (1)

Starscream1984
Starscream1984

Reputation: 3062

No, the comma is more like an OR, it will select targets with either attribute 1 or attribute 2 or both

Upvotes: 1

Related Questions