What is the difference between <html lang="en">
and <html lang="en-US">
? What other values can follow the dash?
According to w3.org "Any two-letter subcode is understood to be a [ISO3166] country code." so does that mean any value listed under the alpha-2 code is an accepted value?
In hreflang en-US means English, targeted at the United States, just en only specifies English, so could be a fallback to other English speaking countries.
The lang global attribute helps define the language of an element: the language that non-editable elements are written in, or the language that the editable elements should be written in by the user.
The lang attribute is an essential component in the basic structure of an HTML document. It's important that we define it correctly because it affects many aspects of user experience. Unfortunately, the negative effects a missing or wrong attribute can have aren't always evident.
xml:lang is defined by XML 1.0 as a common attribute that can be used to indicate the language of any element's contents. This includes any human readable text, as well as other content (such as embedded objects like images or sound files) contained by the element in which it appears.
<html lang="en">
<html lang="en-US">
The first lang
tag only specifies a language code. The second specifies a language code, followed by a country code.
What other values can follow the dash? According to w3.org "Any two-letter subcode is understood to be a [ISO3166] country code." so does that mean any value listed under the alpha-2 code is an accepted value?
Yes, however the value may or may not have any real meaning.
<html lang="en-US">
essentially means "this page is in the US style of English." In a similar way, <html lang="en-GB">
would mean "this page is in the United Kingdom style of English."
If you really wanted to specify an invalid combination, you could. It wouldn't mean much, but <html lang="en-ES">
is valid according to the specification, as I understand it. However, that language/country combination won't do much since English isn't commonly spoken in Spain.
I mean does this somehow further help the browser to display the page?
It doesn't help the browser to display the page, but it is useful for search engines, screen readers, and other things that might read and try to interpret the page, besides human beings.
You can use any country code, yes, but that doesn't mean a browser or other software will recognize it or do anything differently because of it. For example, a screen reader might deal with "en-US" and "en-GB" the same if they only support an American accent in English. Another piece of software that has two distinct voices, though, could adjust according to the country code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With