【发布时间】:2011-06-06 02:02:36
【问题描述】:
我设置了一个简单的测试页面来说明我遇到的问题。 简而言之,这可以按预期工作(文本格式为粗体,带下划线的红色):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
[abc=x1] {
color: red;
text-decoration: underline;
font-weight: bold;
}
</style>
</head>
<body>
<div abc=x1>hello</div>
</body>
</html>
这不会(文本保持黑色,未应用格式):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
[abc=1] {
color: red;
text-decoration: underline;
font-weight: bold;
}
</style>
</head>
<body>
<div abc=1>hello</div>
</body>
</html>
我在两个示例之间唯一更改的是属性值(在 CSS 和 HTML 中)从 x1 到 1。
看来你无法匹配数字属性。
有人知道为什么这个...非常...有用...功能...存在吗?
【问题讨论】:
标签: html css css-selectors