首页 > 解决方案 > CSS 属性选择器匹配 void 值

问题描述

是否可以匹配具有没有值的属性的元素?

即:匹配这个:<element attribute>

匹配这个:<element attribute=""><element attribute=" ">, <element attribute="<any Unicode string>">.

(不使用[attribute]:not([attribute^="a"i]):not([attribute^="b"i]):not([attribute^="<all remaining Unicode characters">)。)

标签: css

解决方案


没有办法用 CSS 来做到这一点,<element attribute>就像<element attribute="">.

您可以在规范中阅读此内容:https ://html.spec.whatwg.org/multipage/syntax.html#attributes-2

空属性语法:只是属性名称。该值隐含地是空字符串。


推荐阅读