Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

การใช้ CSS [แอตทริบิวต์] Selector


ใช้ตัวเลือก [attribute] เพื่อเลือกองค์ประกอบที่มีแอตทริบิวต์ เช่น แอตทริบิวต์ alt หรือแอตทริบิวต์เป้าหมาย เป็นต้น

คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้ตัวเลือก 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>