ฟังก์ชัน attr() ใน CSS ใช้สำหรับดึงค่าของแอตทริบิวต์จากองค์ประกอบที่เลือกมาใช้งาน
คุณสามารถลองรันโค้ดต่อไปนี้เพื่อนำฟังก์ชัน attr() ไปใช้ใน CSS ได้
ตัวอย่าง
<!DOCTYPE html> <html> <head> <style> a:before {content: " (" attr(href) ")";} </style> </head> <body> <h2>Information Resource</h2> <p>Resource: <a href = "https://www.qries.com">Welcome to Qries </a></p> </body> </html>