คุณสามารถใช้ style กับ HTML elements ที่มีแอตทริบิวต์เฉพาะได้ กฎ style ด้านล่างจะ match ทุก input element ที่มี type attribute เท่ากับ text:
input[type="text"]{
color: #000000;
}กฎสำหรับ attribute selector:
- p[lang] - เลือก p ทุกตัวที่มี lang attribute
- p[lang="fr"] - เลือก p ที่ lang attribute เท่ากับ "fr" อย่างแน่นอน
- p[lang~="fr"] - เลือก p ที่ lang attribute มีคำว่า "fr" อยู่
- p[lang|="en"] - เลือก p ที่ lang attribute เป็น "en" หรือขึ้นต้นด้วย "en-"