:lang()
尝试一下
语法
形式语法
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)