简体   繁体   中英

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?

不,逗号更像是OR,它将选择具有属性1或属性2或同时具有两者的目标

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM