You know what language you’re writing in, so tell your readers… and their software.
First, get the right two-character language code. The code for English is “en“; the code for French is “fr“; German is “de“. If you’re writing in another language, look up your language code here. Language codes are not case-sensitive.
Now put your language code in your <html> tag. Exactly how you do this depends on what version of HTML you’re using. Look at your DOCTYPE, then do one of the following:
If you’re using any variant of HTML 4, change your <html> tag to this (use your own language code if not English):
<html lang="en">
If you’re using any variant of XHTML 1.0, change your <html> tag to this (use your language code in both places):
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
If you’re using XHTML 1.1, change your <html> tag to this (again, insert your own language code):
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
Like the DOCTYPE, you should identify your language on every page of your weblog.
One additional note: if you have more than one language on a page, you can identify the language on any enclosing element. For instance, if your weblog uses HTML 4 and is primarily in German, but you quote an article in English, you could mark it up like this:
<html lang="de"> ... <blockquote lang="en"> ... </blockquote>
lang attribute in the HTML specificationlang attribute support in screen readers. He describes their language auto-detection algorithms as “flaky”, and he would know, since he designed the algorithm for Home Page Reader. Other screen readers have added support for the lang attribute since his comments were written, but their auto-detection algorithms are still flaky, making it even more important and useful to identify your language.§
I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)
§
© 2001–9 Mark Pilgrim