:lang(language) (since jQuery 1.9) selects elements whose language matches the given code — equal to it, or starting with that code plus a hyphen (so :lang(en) matches en and en-US, but not english). Language usually comes from the lang attribute (and can inherit from ancestors).
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("div:lang(en)") // lang="en", "en-US", "en-GB", …
$("div:lang(en-us)") // en-us specifically (official demo)
$("p:lang(es)") // Spanish paragraphs
$('[lang="en"]') // exact attribute only — narrower!
// Inheritance: a child without lang= still matches
// if an ancestor sets the language
Call
What it does
:lang()
Learn the jQuery :lang() selector: match elements by language code, prefix matching for en vs en-US, inheritance from ancestors, vs [lang], examples, pitfalls, and FAQs.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Write $(":lang(en)") or $("div:lang(en-us)").
Step 2
Use a short code (en) to catch regional variants (en-US, en-GB).
Step 3
Use a full tag (en-us) when you need one region only.
Return Value
Return Value
Description
See examples
Check the examples below for what this API returns in common cases.
jQuery Examples
Example 1 — Official Demo: div:lang(en-us) / es-es
Mark USA and Spain blocks by language (jQuery API example, CSS-free).
:lang(fr) → 2
[lang="fr"] → 1
Child without lang= still matches :lang(fr)
How It Works
Pseudo.:lang(fr) uses resolved language (including inheritance).
Attribute.[lang="fr"] needs that exact attribute on the element.
Gap. A child without lang matches :lang but not [lang].
Frequently Asked Questions
:lang(language) selects elements whose language matches the supplied language code. $("div:lang(en)") matches lang="en" or lang="en-US" (code plus hyphen suffix), but not unrelated values like lang="english". Available since jQuery 1.9.
[lang="en"] matches only an exact lang attribute on that element. :lang(en) also matches lang="en-US", lang="en-GB", and elements that inherit language from an ancestor with a matching lang value.
Yes. :lang() is defined in the W3C CSS specification. It works in jQuery 1.9+ and in native querySelectorAll(":lang(en)") in modern browsers.
For HTML, language comes from the lang attribute on the element or ancestors, and possibly from meta elements or HTTP headers — as described in the official jQuery documentation.
Official jQuery demo runs $("div:lang(en-us)").addClass("usa") and $("div:lang(es-es)").addClass("spain") to style USA and Spain content blocks by language.
Yes. :lang(en) matches both lang="en" and lang="en-US" because en-US starts with en followed by a hyphen. Use :lang(en-us) when you need that regional tag only.