dir attribute
ATTRIBUTE: lang
lang="languagecode"
The
lang
attribute is used to define the base language to be used for displaying text and characters on a Web site. This allows an internationalization of
HTML
for a very large number of languages.
The languages are designated by a two letter code, such as "en" for English or "el" for Greek. One or more hypenated values can be tacked on to the initial two letter code to specify regional or ethentic variations, such as "en-us" for U.S. English.
Note that .html texts that contain foreign languages that use special characters will have to be saved as a Unicode file, rather than as an ANSI file, in order for the characters to be properly displayed. Please be aware that some browsers may not be capable of correctly displaying a Unicode file.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>DevGuru XHTML lang Attribute Example</title>
</head>
<body>
<span
lang="el"
>
... place text of foreign language here ...
</span>
</body>
</html>
The output example is a Unicode file and may not properly display in some browsers.
Output:
Click to see output in a separate window
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information