A+ A-

Internationalization Attributes of an Html Document

There are three internationalization attributes, which are available for most XHTML elements.



  • dir 
  • lang 
  • xml:lang 


The dir Attribute:

The dir attribute allows you to indicate to the browser about the direction in which the text should flow. The dir attribute can take one of two values, as you can see in the table that follows:



ltr -> Left to right (the default value)
rtl -> Right to left (for languages such as Hebrew or Arabic that are read right to left)



Example :



<!DOCTYPE html>
<html dir="rtl">
<head>
<title>Display Directions</title>
</head>
<body>
This is how IE 5 renders right-to-left directed text.
</body>
</html>



This will produce the following result:

This is how IE 5 renders right-to-left directed text.



When dir attribute is used within the <html> tag, it determines how text will be presented within the entire document. When used within another tag, it controls the text's direction for just the content of that tag.


The lang Attribute:

The lang attribute allows you to indicate the main language used in a document, but this attribute was kept in HTML only for backwards compatibility with earlier versions of HTML. This attribute has been replaced by the xml:lang attribute in new XHTML documents.

The values of the lang attribute are ISO-639 standard two-character language codes. Check HTML Language Codes: ISO 639 for a complete list of language codes.

Example :



<!DOCTYPE html>
<html lang="en">
<head>
<title>English Language Page</title>
</head>
<body>
This page is using English Language
</body>
</html>



The xml:lang Attribute:



The xml:lang attribute is the XHTML replacement for the lang attribute. The value of thexml:lang attribute should be an ISO-639 country code as mentioned in previous section.



Generic Attributes:

Some other attributes that are readily usable with many of the HTML tags.



align - right, left, center - Horizontally aligns tags
valign - top, middle, bottom - Vertically aligns tags within an HTML element.
bgcolor - numeric, hexidecimal, RGB values - Places a background color behind an element
background - URL - Places a background image behind an element
id - User Defined - Names an element for use with Cascading Style Sheets.
class - User Defined - Classifies an element for use with Cascading Style Sheets.
width - Numeric Value - Specifies the width of tables, images, or table cells.
height - Numeric Value - Specifies the height of tables, images, or table cells.
title - User Defined - "Pop-up" title of the elements.