asp.net.ph

Skip Navigation LinksAbakada: Back to Basics > Language References > CSS Properties > Pseudo-Classes > lang( ) Pseudo-class

:lang( ) Pseudo-class


Matches elements with a specified language value.

Syntax

selector:lang( languagecode ) {
   property: value
}

Possible Values

languagecode A comma separated list of one or more strings that denote an element with a language value according to BCP47 language codes.
property Any valid CSS property.
value Any of the range of values available to the corresponding property.

Remarks

The :lang( ) pseudo-class applies styles to elements that match a specified language attribute value.

The language attribute value can be a two-letter primary language tag with no additional qualifiers, like de ( German ), or a primary language tag with a region subtag, like de-AT ( German for Austria ).

The syntax for using the :lang( ) pseudo-class is straightforward. A selector immediately precedes the pseudo-class.

For example, to set the style of <main> elements with a language value of fr ( French ):

main:lang( fr ) { background-color: beige }

which will apply the style to the element with a matching lang attribute.

<main lang="fr"> ... <main>

Example

The following demonstrates use of the :lang( ) pseudo-class in an embedded stylesheet to set the style of elements of a given language on a page.

External References

See Also



Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note