:lang()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
尝试一下
语法
形式语法
css
:lang(<language-code>) {
/* ... */
}
参数
示例
HTML
html
<div lang="en">
<q>This English quote has a <q>nested</q> quote inside.</q>
</div>
<div lang="fr">
<q>This French quote has a <q>nested</q> quote inside.</q>
</div>
<div lang="de">
<q>This German quote has a <q>nested</q> quote inside.</q>
</div>
CSS
css
:lang(en) > q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
:lang(fr) > q {
quotes: "« " " »";
}
:lang(de) > q {
quotes: "»" "«" "\2039" "\203A";
}
结果
规范
Specification |
---|
Selectors Level 4 # lang-pseudo |
浏览器兼容性
BCD tables only load in the browser
参见
- 语言相关伪类:
:lang
、:dir
- HTML
lang
属性 - HTML
translate
属性 - RFC 5646: 用于标识语言的标签(也称为 BCP 47)