Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

CSS Descendant Selector (space)


เลือกหลานทุกระดับ

ใช้ div p (เว้นวรรค) เพื่อเลือก <p> ทุกตัวที่อยู่ภายใน <div> ไม่ว่าจะลึกแค่ไหน

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    div p {
      background-color: orange;
    }
  </style>
</head>
<body>
  <div>
    <p>Para 1 in the div</p>
    <p>Para 2 in the div</p>
  </div>
  <p>Para 3 outside the div.</p>
</body>
</html>