Internationalization

Internationalization

These attributes help to support different languages and character sets in web pages and are

  •  dir
  •  lang
  • xml:lang

Support of these attributes is at different levels in different browsers so, character set should be specified. These attributes are also called as the i18n attributes, due to the draft name on which it is defined.

dir Attribute

It indicates direction of text flow i.e. left to right or right to left. It can be used on elements to change the direction of that portion of the document and to change directionality of a whole document then use this attribute in <html> element. Its usage is

dir=”ltr|rtl”

It can have two values as

Value Meaning
ltr Left to right (default)
rtl Right to left

lang Attribute

It tells the language used in a web page and used for compatibility with older versions of HTML, and now ‘xml: lang’ attribute is used. Hence, both ‘lang’ and ‘xml:lang’ attributes to be used for maximum compatibility.

It has low effect in browsers but mainly used for search engines to tell the language of web page is made in. It can be applied to the content of a specific element if used on it but to apply on whole document it is used on <html> element.

Its values are described by ISO-639 standard consisting of two-character language codes and with a dash and a sub-code name for any further dialect. The table that follows offers some examples.

lang=”en”

Value Meaning
en English
en-us U. S. English

It is used in webpage as

<html lang=en>

<head>

<title>English Language Page</title>

</head>

<body>

This page is using English Language

</body>

</html>

The xml:lang Attribute

It replaces the ‘lang’ attribute and supports all languages that are written in XML so, it has ‘xml:’ characters prefixed. Its value is same as of ‘lang’ attribute i.e. an ISO-639 code.

It is used as

xml:lang=”en”

XML-aware applications and search engines use it. If applied to <html> element then it applies to whole web page and if used with specific elements it just applies to content of that element.

Core Attributes
UI Events

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?