English Isn t the Only Language


English Isn't the Only Language

You can use HTML even if you don't write in English. URLs, hyperlinks, HTML tags, and document formatting elements are language neutral, but text requires a specification all its own. If you write in standard U.S. English, you don't need to make any changes to the way you create your HTML documents. If you are writing text in any other language, however, you should specify the language for the browser. The following HTML samples show the designations for German and French.

<html xmlns="http://www.w3.org/1999/xhtml"        xml:lang="de" lang="de">


and

<html xmlns="http://www.w3.org/1999/xhtml"        xml:lang="fr" lang="fr">


The language attributes (xml:lang and lang) support the same values as ISO, the International Standards Organization. You can see the full list of supported languages and their codes at www.loc.gov/standards/iso639-2/langcodes.html.

Tip

Why is language important? Browsers do not recognize the language you type unless you use the lang attribute. Some search engines use the lang attribute to return only pages written in a specific language. Speech synthesizers use this information to aid in pronunciation. Even some spelling checkers can use the information to recognize misspellings.


Mixing Languages in a Single Page

Although the preceding example shows the lang attribute used as part of the <html> tag at the top of your document, it's possible that you would want to include text of one language within a document of another languagefor example, including a paragraph in French within a document in English. You can assign the lang attribute to the <p> tag to solve this problem. Look at the following sample:

<!DOCTYPE html      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-      transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"        xml:lang="en" lang="en"> <head> <title>Multi-Language Document</title> </head> <body> <p>Put your English text here.</p> <p lang="fr">Mettez votre texte français ici.</p> <p lang="en">Put the rest of your English text here.</p> </body> </html>




Sams Teach Yourself HTML in 10 Minutes
Sams Teach Yourself HTML in 10 Minutes (4th Edition)
ISBN: 067232878X
EAN: 2147483647
Year: 2004
Pages: 151
Authors: Deidre Hayes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net