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

วิธีเลือกองค์ประกอบด้วยแอตทริบิวต์ที่ระบุด้วย CSS


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

ตัวอย่างเช่น แอตทริบิวต์ 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>