Attribute Selector ([…])

W3C CSS Snapshot 2026

Attribute ပါမပါ ဒါမှမဟုတ် တန်ဖိုး ဘယ်လိုရှိလဲ ကြည့်ပြီး ရွေးဖို့ [ ] သုံးပါ။

ဒီစာမျက်နှာမှာ

ရေးပုံနဲ့ သုံးလို့ရတဲ့ တန်ဖိုးများ

တန်ဖိုး သို့မဟုတ် ရေးပုံအလုပ်လုပ်ပုံ
[required]required attribute ပါပါတယ်။
[type="email"]type တန်ဖိုးက email ဖြစ်ပါတယ်။
[class~="notice"]space နဲ့ ခွဲထားတဲ့ class စာရင်းထဲမှာ notice တစ်လုံးအဖြစ် ပါပါတယ်။
[lang|="en"]တန်ဖိုးက en ဖြစ်ပါတယ်၊ ဒါမှမဟုတ် en- နဲ့ စပါတယ်။
[href^="https:"]တန်ဖိုးက https: နဲ့ စပါတယ်။
[href$=".pdf"]တန်ဖိုးက .pdf နဲ့ ဆုံးပါတယ်။
[href*="guide"]တန်ဖိုးထဲမှာ guide ပါပါတယ်။
[data-region="mm" i]i သုံးရင် ASCII စာလုံး အကြီး၊ အသေး မခွဲဘဲ ရွေးပါတယ်။ Browser က ပံ့ပိုးရင် s နဲ့ အကြီး၊ အသေး ခွဲနိုင်ပါတယ်။

နမူနာကို စမ်းကြည့်ပါ

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Attribute Selector ([…])</title>
  <style>
input[type="email"] { border: 2px solid teal; }
[required] { background: #eff9ff; }
  </style>
</head>
<body>
<label>Email <input type="email" required></label>
<label>Name <input type="text"></label>
</body>
</html>

စမ်းကြည့်ရင် ဘာဖြစ်မလဲ Email field မှာ ဘောင်နဲ့ နောက်ခံရောင် ပေါ်ပါတယ်။ Name field က rule နှစ်ခုလုံးနဲ့ မကိုက်ပါဘူး။

တရားဝင် ကိုးကားချက်များ