Webmaster Resources Center

Welcome to the Bravenet Resource Center. Use these resources to help make your web pages more advanced and fun to use.

Quick Reference Sheets for Webmasters

Quick Reference sheets are packed full of useful information for all webmasters.

HTML Reference Sheet

Language Information

This portion of the reference discusses two important issues that affect the internationalization of HTML: specifying the language and direction of text in a document.

Specifying the language of content; the lang attribute

lang=language-code This attribute specifies the base language of an element's attribute values and text content. The default value of this attribute is unknown.

To set the default language for the entire html document, we do so by applying the lang attribute to the html tag.

<html lang="en">
... head, body, etc. goes here ...
</html>

An element inherits language code information according to the following order of precedence (highest to lowest):

  • The lang attribute set for the element itself.
  • The closet parent element that has the lang attribute set
  • The HTTP "Content-Language" header which may be configured by the web server or within a Meta tag.
  • Browser default values and user preferences.

The following example shows how the primary language of a document can be set while one paragraph is declared to be in an alterantive language.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Jedi Master Guild. Join with the Forces</title>
<meta name="Author" content="John Doe" />

</head>
<body>
<h1>Welcome to Jedi Master Guild</h1>
<p lang="fr">
... paragraph set to use character set for the french language ...
</p>
<h2>Introduct to Jedi Mastering</h2>
<p>
... some paragraph of text ...
</p>
</body>
</html>

There are many language codes available for various languages. View Character Codes.

Specifying the direction of text and tables: the dir attribute

In addition to specifying the language of a document with the lang attribute, authors may need to specify the base directionality (left-to-right or right-to-left) of portions of a document's text, of table structure, etc. This is done with the dir attribute.

dir=ltr|rtl This attribute specifies the base direction of directionally neutral text (i.e., text that doesn't have inherent directionality as defined in [UNICODE]) in an element's content and attribute values. It also specifies the directionality of tables. ltr value specifies Left-to-right text or table while the rtl value specifies Right-to-left

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" dir="ltr">
<head>
<title>Jedi Master Guild. Join with the Forces</title>
<meta name="Author" content="John Doe">

</head>
<body>
<h1>Welcome to Jedi Master Guild</h1>
<p lang="fr">
... paragraph set to use character set for the french language ...
</p>
<h2>Introduct to Jedi Mastering</h2>
<p>
... some paragraph of text ...
</p>
</body>
</html>