CSS [attribute] 选择器的用法


使用 [attribute] 选择器,以选择具有属性的元素,例如 alt 属性或 target 属性等。

可以尝试运行以下代码以实现 CSS[attribute] 选择器。

示例

在线演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         img[alt] {
            border: 3px solid orange;
         }
      </style>
   </head>
   <body>
      <img src = "https://tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg"
         height="200" width="200">
      <img src = "https://tutorialspoint.com/videotutorials/images/tutorial_library_home.jpg"
         height = "200" width="200" alt = "Tutorials Library">
   </body>
</html>

更新于:2020 年 6 月 23 日

227 次浏览

开启你的 职业生涯

通过完成课程获得认证

开始学习
广告
© . All rights reserved.