:lang()

Псевдо-класс CSS :lang() выбирает элементы основываясь на языке, на котором они определены.

css
/* Выбирает все <p>, что на английском (en) */
p:lang(en) {
  quotes: "\201C" "\201D" "\2018" "\2019";
}

Примечание: В HTML язык определяется комбинацией атрибута lang, элемента <meta> и иногда информацией из протокола (такой, как заголовки HTTP ). Для других типов документов могут быть другие методы определения языка.

Синтаксис

Формальный синтаксис

Error: could not find syntax for this item

Параметр

<language-code>

<string> (en-US), представляющая язык, который вы хотите отобрать. Допустимые значения указаны в документации HTML.

Пример

In this example, the :lang() pseudo-class is used to match the parents of quote elements (<q> (en-US)) using child combinators. Note that this doesn't illustrate the only way to do this, and that the best method to use depends on the type of document. Also note that Unicode (en-US) values are used to specify some of the special quote characters.

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

Также смотрите