当前位置: 代码迷 >> 综合 >> day34-36属性选择器
  详细解决方案

day34-36属性选择器

热度:59   发布时间:2023-12-12 03:51:21.0

当元素里没有id和class,且不能通过元素直接找到怎么办?
用属性选择器!
示例代码:

<!DOCTYPE html>
<html>
<head>
<style> a[target=_blank] {
      background-color:yellow; } </style>
</head>
<body><p>target="_blank" 的链接会得到黄色背景:</p><a href="http://www.w3school.com.cn">w3school.com.cn</a>
<a href="http://www.disney.com" target="_blank">disney.com</a>
<a href="http://www.wikipedia.org" target="_top">wikipedia.org</a><p><b>注释:</b>对于 IE8 及更早版本的浏览器中的 [<i>attribute</i>],必须声明 <!DOCTYPE>。</p>
</body>
</html>