W3C 建议定义了使用 选择具有已定义类的任何锚点的能力A[CLASS]{/*Code*/}
,但是有先例吗?
我可以选择所有没有类的锚吗?
我的直觉是使用A[~CLASS]{/*Code*/}
,但这没有记录,并A[CLASS=]{/*Code*/}
选择所有类名为空字符串的锚(例如,<A CLASS="" HREF="http://example.com/">This anchor has a class, but it's empty.</A>
)。
示例用法
在这段代码中,我只希望无类链接是绿色的。
<HTML>
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" HREF="http://example.com/externalUneditableStyles.CSS" />
<STYLE>
A.deadLink{
color:#FF0000 !important;
}
A{
color:#00FF00;
}
</STYLE>
</HEAD>
<BODY>
<A HREF="http://fakesite.not/" CLASS="deadLink">This link is red, as specified by the CSS above.</A>
<A HREF="http://example.com/">This link is green, as specified by the CSS above.</A>
<A HREF="#/childpage/" CLASS="childLink">This is a link to a child page, and is styled by external uneditable CSS. That CSS doesn't specify a color, so it is green, even though that might not be the intended effect.</A>
</BODY>
</HTML>