: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).
Remember
$("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
Pass a language code, optionally prefix with a tag, then style or count matches.
Write $(":lang(en)") or $("div:lang(en-us)").
Use a short code (en) to catch regional variants (en-US, en-GB).
Use a full tag (en-us) when you need one region only.
Remember descendants inherit language from ancestors without their own lang.
Prefer :lang() over [lang=…] when inheritance or prefix matching matters.
Piece
Required?
Role
language argument
Yes
Language code such as en, en-us, es
Tag prefix
Optional
Limits matches to one element type (div:lang(…))
lang attribute
On tree
Sets language on the element or an ancestor
Return value
—
jQuery collection of matching elements (may be empty)
Pseudocode
Pseudocode
matches = []
for each element in search context:
lang = resolved language of element
(own lang=, or inherited from ancestor)
if lang equals code
or lang starts with code + "-":
matches.add(element)
return matches
// :lang(en) → en, en-US, en-GB
// :lang(en) ✗ english (no hyphen after "en")
Reference
Cheat Sheet
Keep these facts handy while matching by language.
Topic
Detail
Syntax
$(":lang(language)")
Since
jQuery 1.9 · standard CSS
Prefix rule
en matches en-US
Inheritance
Children inherit ancestor language
vs [lang]
Attribute = exact value, no inherit
Official demo
div:lang(en-us) / div:lang(es-es)
Case
Language codes are case-insensitive
Native CSS
Yes — works in querySelectorAll
Try it
Live Preview
Run different language selectors against a small multilingual sample and see how many elements match.
red
white
rojo
Hello
Bonjour
Sample includes nested en-us / es-es divs (official style) plus lang="en" and lang="fr" paragraphs.
Result
$("div:lang(en-us)")
matched: 3
/* parent + two children inherit en-us */
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console with jQuery loaded, or use Try It Yourself for a live editor.
Example 1 — Official Demo: div:lang(en-us) / es-es
Mark USA and Spain blocks by language (jQuery API example, CSS-free).
German articles: 1
[DE] shown only on the de article
How It Works
Tag.article limits the search to article elements.
Language.:lang(de) keeps German content only.
Other tags. A German p elsewhere is ignored.
Label. Prepending [DE] shows which article matched.
Edge Cases & Pitfalls
Check these before relying on :lang() in multilingual pages.
prefix
:lang(en) ≠ the word “english”
Matching needs equality or a hyphen suffix (en-US). lang="english" does not match.
inherit
Children inherit language
A nested element without lang still matches if an ancestor sets the language.
attr
[lang="en"] is narrower
Exact attribute only — no prefix match, no inheritance. Prefer :lang(en) for language-aware selection.
version
Needs jQuery 1.9+
:lang() was added in jQuery 1.9. Older builds will not recognize it.
Compatibility
Browser Support
The :lang() pseudo-class is standard CSS and has been available in jQuery since 1.9. Modern browsers also support it in native querySelectorAll(":lang(en)").
✓ jQuery 1.9+ · CSS standard
jQuery :lang() Selector
Supported in jQuery 1.9+ and native CSS across modern browsers. Prefer :lang() for inheritance and prefix matching; use [lang] for exact attributes.
100%CSS + jQuery 1.9+
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
:lang()Universal (modern)
Bottom line: Safe in jQuery 1.9+ and modern browsers. Use short codes for language families; full tags for one region.
Analysis
Performance Notes
Approach
Cost
Best for
$("div:lang(en)")
Fast
Tag-scoped language match (native CSS)
$("#main :lang(en)")
Cheaper
Large pages — limit the search root
$(":lang(en)")
OK
Small documents
$('[lang^="en"]')
Different
Exact attributes only — no inheritance
Because :lang() is standard CSS, modern browsers can run it via querySelectorAll. Scope with a tag or container when the DOM is large.
Remember
Key Takeaways
Role: select elements by resolved language code.
Prefix::lang(en) matches en and en-US.
Inherit: children without lang still match ancestors.
vs attr:[lang] is exact — no prefix, no inheritance.
One line:$(":lang(en)") finds English content — including en-US and inherited language — while [lang="en"] is exact-only.
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.