CSS 中 :lang 伪类的用法

cssweb developmentfront end technology更新于 2025/8/23 23:40:17

使用 :lang 伪类指定在特定元素中使用的语言。此类在必须支持多种语言且对某些语言结构有不同约定的文档中非常有用。

示例

您可以尝试运行以下代码来了解 :lang 伪类的用法

<html>
   <head>
      <style>
         /* Two levels of quotes for two languages*/
         :lang(en) { quotes: '"' '"' "'" "'"; }
         :lang(fr) { quotes: "<<" ">>" "<" ">"; }
      </style>
   </head>
   <body>
      <p>...<q lang="fr">A quote in a paragraph</q>...</p>
   </body>
</html>

相关文章


有用资源