Intended audience: users, XHTML/HTML coders (using editors or scripting), script developers (PHP, JSP, etc.), CSS coders, Web project managers, and anyone who wants to know how language declarations work in current browsers.
These tests check whether user agents recognize language declarations for HTML documents, and apply the expected prioritisation in case of mismatches between multiple declarations.
Note that the snapshot summaries of these test results are for released versions of the browsers tested. Versions that are still in development may provide better support for these features. The tests themselves do not test any vendor prefixes.
In order to tell whether the language information is available we use :lang
. We run control tests that will raise a flag if :lang
is not supported by the browser.
The tables show results for tests run on the date shown. Above the tables are summaries of the results at that date. The table data may be more up-to-date than the summary. If the tables contain some incorrectly scored tests, or tests that relate to non-released versions of browsers, these are not included in the summary.
To see the test, click on the link in the left-most column. To see detailed results for a single test, click on the link in the right-most column. All browsers tested recognized language declarations in the If All the most recent versions of browsers recognised declarations in the HTTP header, however slightly older versions of Opera and Safari don't. The version of Safari tested that failed is the standard version for Snow Leopard. The version of Opera runs on the Presto engine. Declarations in the These results would indicate that declaring language for text-processing purposes can be done in the Links: Section 3.2.3.3 • Related tests If a browser version doesn't pass the test the-lang-attribute-003 above, you should ignore the results for tests -005 and -006. If a browser version doesn't pass the test the-lang-attribute-004 above, you should ignore the results for tests -006 and -007. This summary focuses on only the most recent versions of the browsers tested In-page declarations always have precedence over the HTTP declaration. A language attribute with a value always has precedence over the Links: Section 3.2.3.3 • Related tests If a browser version doesn't pass the test the-lang-attribute-003 above, you should ignore the results for test -009. If a browser version doesn't pass the test the-lang-attribute-004 above, you should ignore the results for test -010. This summary focuses on only the most recent versions of the browsers tested. An empty An empty value in a An empty The Firefox behaviour is unexpected, because when the attribute on the html tag has a value it does take precedence over the HTTP header (see the earlier section). The question is whether this is a bug due to a misinterpretation of the meaning of the empty language value. Links: Section 3.2.3.3 • Related tests If a browser version doesn't pass the test the-lang-attribute-003 above, you should ignore the results for test -011. If a browser version doesn't pass the test the-lang-attribute-004 above, you should ignore the results for test -012. This summary focuses on only the most recent versions of the browsers tested. Only IE, Safari and Opera ignored the HTTP declaration when it had multiple values. In Chrome and Firefox the language of the element tested had been set to all three languages of the list in the HTTP header. This doesn't really make sense. All the browsers except Firefox ignored the declarations where the Links: Section 4.2.5.3 • Related tests
Basic declarations
Snapshot summary, 2014-02-17
Firefox 27.0, Chrome 32.0.1700.107, Safari 6.1.1, Internet Explorer 9, Opera 19.0html
tag using the lang
attribute. xml:lang
is used instead of the lang
attribute, the declaration is not recognized, which is to be expected.meta
pragma-set default were recognized by all recent versions of browsers tested, however not in the Presto-based older version of Opera. html
tag, the HTTP header or the meta
element as long as the user has access to the latest versions of those browsers. However this is not the case for slightly older versions of some browsers, so it is still best done in the html
tag.
Test link
Assertion
Details
lang attribute in html tag
The browser will recognize a language declared in a lang attribute on the html tag.
the-lang-attribute-001
xml:lang attribute in html tag
The browser will NOT recognize a language declared in an xml:lang attribute on the html tag.
the-lang-attribute-002
HTTP header
The browser will recognize a language declared in the HTTP header, when there is no internal language declaration.
the-lang-attribute-003
pragma-set default
The browser will recognize a language declared in a meta element in the head using http-equiv='Content-Language' content='..' (with a single language tag value), when there is no other language declaration inside the document.
the-lang-attribute-004
Conflicting declarations
Snapshot summary, 2014-02-17
Firefox 27.0, Chrome 32.0.1700.107, Safari 6.1.1, Internet Explorer 9, Opera 19.0meta
element.
Test link
Assertion
Details
HTTP header and html lang
If there is a conflict between the language declarations in the HTTP header and the html element using lang, the browser will recognize the language declared in the html element.
the-lang-attribute-005
HTTP header and meta element
If there is a conflict between the language declarations in the HTTP header and the Content-Language meta element, the UA will recognize the language declared in the meta element.
the-lang-attribute-006
html lang and meta elements
If there is a conflict between the language declared using lang in the html element and that in the meta element, the UA will recognize the language declared in the html element.
the-lang-attribute-007
Empty language value
Snapshot summary, 2014-02-17
Firefox 27.0, Chrome 32.0.1700.107, Safari 6.1.1, Internet Explorer 9, Opera 19.0lang
attribute value overrode an earlier lang
attribute in all browsers.lang
attribute killed any value from the HTTP declaration in IE, Chrome, Safari and Opera, but not in Firefox. lang
value on the html
element killed any default value from the meta
element, except (again) for Firefox.
Test link
Assertion
Details
lang="..." vs lang=""
If an element contains a lang attribute with an empty value, the value of a lang attribute higher up the document tree will no longer be applied to the content of that element.
the-lang-attribute-008
lang="" vs HTTP
If the HTTP header contains a language declaration but the html element uses an empty lang value, the UA will not recognize the language declared in the HTTP header.
the-lang-attribute-009
lang="" vs meta Content-Language
If the meta Content-Language element contains a language declaration but the html element uses an empty lang value, the UA will not recognize the language declared in the meta Content-Language element.
the-lang-attribute-010
Declarations containing multiple languages
Snapshot summary, 2014-02-17
Firefox 27.0, Chrome 32.0.1700.107, Safari 6.1.1, Internet Explorer 9, Opera 19.0meta
element value contained multiple languages. Again, Firefox set the language of the text to three languages, which doesn't make sense for text-processing.
Test link
Assertion
Details
Multiple languages in HTTP header
[Exploratory] The browser will not recognize a language declaration in the HTTP Content Language header when more than one language is declared.
the-lang-attribute-011
Multiple languages in Content-Language meta element
The UA will not recognize a language declaration in the Content-Language meta element when more than one language is declared.
the-lang-attribute-012