Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xhtml document - Lang options question

What is the difference between the 2 lines shown below?:

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

<meta http-equiv="content-language" content="en-GB" />

If i didn't have the meta tag, what would be the consequence?

Does the meta one affect screen readers and the top one not? I'm a bit confused as to what exactly they do.

Thanks in advance for any help

Best regards

Skip.

like image 851
Skip Avatar asked Mar 01 '23 19:03

Skip


2 Answers

Dive Into Accessibility's Identifying your language page recommends adding as much as possible to handle as many screen readers as you can, depending on your doctype:

If you're using any variant of HTML 4, change your 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 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 tag to this (again, insert your own language code):

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

The same article also references ISO 639.2 to determine what the value of xml:lang should be, although the XML specification references a separate document, RFC4646 Best Current Practice - Tags For Identifying Languages, which seems to indicate your value of "en-GB" is valid.

Google's Web Authoring Statistics (2005) have the following to say about it:

Next is the Content-Language value (used on the http-equiv attribute). Almost as many people use this as specify the lang attribute on the html element. In the HTML5 spec currently the http-equiv attribute is only allowed for the one case of setting the character encoding, which can't really be dropped, as the graph above demonstrates. However, http-equiv="Content-Language" is supported by at least one browser, and as we see here, it is widely used — maybe http-equiv should not be removed after all.

Further, a thread on webproworld talks about the difference between using http-equiv=content-language and name=language to describe the language of the document and implies that both are necessary.

Finally, refer to the HTML Techniques for Web Content Accessibility Guidelines 1.0 document at W3C for some more recommendations, specifically Identifying the Primary Language.

In conclusion it looks like screen readers are looking at lang attributes more than content-language meta information, but most recommendations I've seen advise using meta data anyway. Especially the Google statistics seem pertinent, so perhaps you should leave both in.

like image 175
Rahul Avatar answered Mar 07 '23 06:03

Rahul


I believe one advantage of the <meta> version is that you can specify multiple languages, as in <meta http-equiv="Content-Language" content="en-GB, fr" />, for example. Have a look at this for a more in-depth examination of the subject.

like image 32
hbw Avatar answered Mar 07 '23 04:03

hbw