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

บทบาทของ CSS :lang Selector


จัดสไตล์ตามภาษาที่กำหนดในแอตทริบิวต์ lang

ใช้ :lang(fr) เลือกองค์ประกอบที่มี lang="fr" (ภาษาฝรั่งเศส)

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    p:lang(fr) {
      background: green; /* ตัวอย่างเดิมเขียน greeb ผิด */
    }
  </style>
</head>
<body>
  <p>This is my country</p>
  <p lang="fr">C'est mon pays</p>
  <p>French is the language of France</p>
</body>
</html>