HTML XHTML The Complete Reference
home » reference » appendix a » language attributes reference

Language Attributes Reference

A main goal of the HTML and XHTML specifications is to provide better support for languages besides English. The use of other languages in a Web page might require that text direction be changed from left to right or right to left. Once supporting non-ASCII languages becomes easier, it might be more common to see documents in mixed languages. Thus, there must be a way to indicate the language in use and its formatting. The basic language attributes are summarized here to avoid redundancy.

The lang attribute indicates the language being used for the enclosed content. The language is identified using the ISO standard language abbreviations, such as fr for French, en for English, and so on. RFC 1766 ( describes these codes and their formats.

The dir attribute sets the text direction as related to the lang attribute. The accepted values under the HTML 4.01 specification are ltr (left to right) and rtl (right to left). It should be possible to override whatever direction a user agent sets by using this attribute with the bdo element:

<bdo dir="rtl">
Napoleon never really said "Able was I ere I saw Elba."

Internet Explorer 5.5 and higher supports dir for the bdo element, but Netscape 6 does not. If used with other block-level elements, such as p and div, the dir attribute might produce right-aligned text, but it will not change the actual direction of the text flow.

Next: Common Internet Explorer Attributes Reference
(X)HTML Elements
CSS Properties
< Home | About | Chapters | Examples | Errata | Reference | Site Map >