Using the lang attribute makes a difference

About a year ago I posted a Quick Tip titled Specify each HTML document’s main natural language. The reason is that software like screen readers can use this info to adjust the way they speak text.

But do they really do that? Well, it depends. You need to use a screen reader that supports language switching and can speak the natural languages of the document you’re viewing. One example of when it works as expected is VoiceOver for the iPhone and for the iPod touch.

Here are a few examples of text in different languages (thank you, Wikipedia).

Svenska

Välkommen till Wikipedia, den fria encyklopedin som alla kan redigera.

Deutsch

Wikipedia ist ein Projekt zum Aufbau einer Enzyklopädie aus freien Inhalten in allen Sprachen der Welt.

Français

Bienvenue sur Wikipédia, le projet d’encyclopédie libre que vous pouvez améliorer.

Español

Bienvenidos a Wikipedia, la enciclopedia de contenido libre que todos pueden editar.

If you have an iPhone or iPod touch, try loading this page after switching VoiceOver on (in Settings > General > Accessibility > VoiceOver). Each language example should be spoken in a different voice and with correct pronunciation instead of with a heavy English accent. This obviously makes it much easier to understand what VoiceOver is saying.

So yes, specifying the natural language does make a difference.

Posted on April 5, 2010 in (X)HTML, Accessibility

Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.