使用 CSS 为每个带有 lang 属性值的元素添加样式

cssweb developmentfront end technology更新于 2025/5/15 7:40:17

使用 CSS :lang 选择器为每个带有 lang 属性值的 <p> 元素添加样式。您可以尝试运行以下代码来实现  :lang 选择器:

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         p:lang(fr) {
            background: green;
         }
      </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>

相关文章


有用资源