- Text Emphasis
- Special Characters
- Math and Science Notations
- English Isn't the Only Language
- Meta Tags
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 British, English, and French.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-br" lang="en-br">
<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 http://www.oasis-open.org/cover/iso639-2a.html.
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" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <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-US">put the rest of your English text here.</p> </body> </html>