
In HTML, the human language that an element is expressed in can be encoded in the web page. With CSS2, you can select elements on the basis of their human language encoding.
To specify the language of an element in HTML 4.0, you use the lang attribute in the following way. If a paragraph is in a particular language, this is encoded as <p lang="language code"> where language code is usually a two character standard code for common languages. For example, French has the language code "fr", while Chinese the code "zh". The above examples would be <p lang="fr"> and <p lang="zh">, for French and Chinese respectively.
The language pseudo class selector allows developers to select elements encoded in a particular language.
To select a particular element based on its language encoding, simply add :lang(language code) to the selector for the element. For example, to select quotes in French, we have the selector q:lang(fr).
Different languages have different formatting conventions, for queues such as use of italics and bold, indenting, quotation marks and so on. This selector allows one style sheet to describe how elements should appear in different languages. This way, a single style sheet could easily be shared by a multi-lingual organization or company.
| Internet Explorer | Netscape Navigator | Opera | WebTV | ||||||||
| Windows | Macintosh | (All Platforms) | (All Platforms) | ||||||||
| 4.0 | 5.0 | 5.5 | 6.0 | 4.0 | 4.5 | 5.0 | 4.x | 6.0 | 3.5 | 5.0 | 1.0 |
| N | N | N | N | N | N | Y | N | N | N | N | N |