是否可以在主体部分内添加CSS选择器?例如,这是我的代码(但不起作用):
<html>
<head>
</head>
<body>
<div style= "a[target=_blank] {background-color: yellow;}"> **css selector on this section
<a href="http://test.com">test</a>
<a href="http://test1.com" target="_blank">test1</a>
<a href="http://test2.com" target="_top">test2</a>
</div>
</body>
</html>
答案 0 :(得分:1)
否,您不能在嵌入式样式中使用选择器。内联样式只会影响样式标签所在的元素。
答案 1 :(得分:0)
在样式表中使用CSS时似乎工作正常。
据我所知,内联样式仅影响样式处于启用状态的元素,因此不能用于更改其他样式。
a[target=_blank] {
background-color: yellow;
}
<html>
<head>
</head>
<body>
<div>
<a href="http://test.com">test</a>
<a href="http://test1.com" target="_blank">test1</a>
<a href="http://test2.com" target="_top">test2</a>
</div>
</body>
</html>