Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between <html lang="en"> and <html lang="en-US">?

Tags:

html

lang

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?

like image 456
Celeritas Avatar asked Jul 03 '12 20:07

Celeritas


People also ask

What is difference between en and en us?

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.

What is lang in this tag P lang en us?

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.

Is HTML lang en necessary?

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.

What is xml lang in HTML?

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.


2 Answers

<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.

like image 124
Jeremy Wiggins Avatar answered Nov 16 '22 01:11

Jeremy Wiggins


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.

like image 39
woz Avatar answered Nov 16 '22 01:11

woz