首頁  >  文章  >  web前端  >  使用 CSS 選擇所有具有 alt 屬性的元素

使用 CSS 選擇所有具有 alt 屬性的元素

王林
王林轉載
2023-08-26 17:05:021287瀏覽

使用 CSS 选择所有具有 alt 属性的元素

要選擇具有屬性的元素,請使用 CSS [attribute] 選擇器。

例如 alt 屬性或 target 屬性等。

您可以嘗試執行以下程式碼來實作 CSS[attribute] 選擇器,

範例

即時示範

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

以上是使用 CSS 選擇所有具有 alt 屬性的元素的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除