:has()

W3C CSS Snapshot 2026

Child ဒါမှမဟုတ် နောက်က ကပ်လျက် sibling နဲ့ ဆက်နွှယ်ပုံကို ကြည့်ပြီး element ကို ရွေးပါတယ်။

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

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

တန်ဖိုး သို့မဟုတ် ရေးပုံအလုပ်လုပ်ပုံ
section:has(> h2)တိုက်ရိုက် child ထဲမှာ <h2> ပါတဲ့ section ကို ရွေးပါတယ်။
h2:has(+ p)<p> ကပ်လျက်နောက်က လိုက်တဲ့ <h2> ကို ရွေးပါတယ်။
label:has(+ input[required])required input ကပ်လျက်နောက်က လိုက်တဲ့ label ကို ရွေးပါတယ်။

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

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>:has()</title>
  <style>
section:has(> h2) { border: 2px solid teal; }
  </style>
</head>
<body>
<section><h2>Workshop</h2><p>Bring a notebook.</p></section>
<section><p>Open seating.</p></section>
</body>
</html>

စမ်းကြည့်ရင် ဘာဖြစ်မလဲ ခေါင်းစဉ်ပါတဲ့ section မှာပဲ ဘောင် ပေါ်ပါမယ်။

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