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

เลือกทุกองค์ประกอบที่มี alt attribute ด้วย CSS

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

เช่น แอตทริบิวต์ alt หรือ target เป็นต้น

ตัวอย่าง

<!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>