CSS:lang 选择器的作用

cssweb developmentfront end technology更新于 2025/5/15 8:12:17

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

示例

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

相关文章


有用资源