Attribute Selectors
Attribute selectors target elements based on their HTML attributes, not just classes or IDs.
Basic Attribute Selector
Select elements that have a specific attribute:
Loading Selector Playground...
[placeholder]- elements with a placeholder attribute[href]- elements with an href attribute[type]- elements with a type attribute
Exact Value Match
Select elements with a specific attribute value:
Loading Selector Playground...
[type="email"]- input with type exactly "email"[type="password"]- input with type exactly "password"
Styling Form Inputs
Loading CSS Playground...
Links with Attributes
Loading Selector Playground...
Try:
[href]- all links with href[target="_blank"]- external links (new tab)
Data Attributes
Custom data attributes are perfect for attribute selectors:
Loading CSS Playground...
Exercise: Style Required Inputs
Add a red border to required inputs:
Loading CSS Exercise...
التالي · الدرس 9 من 27
Attribute Value Matching
قراءة 2 دقيقة
أنهيت 8 من 27 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

