Which Language Attribute is Correct?
Asked Answered
O

3

6

I'm sure this has been asked a million times before, and I've googled it a few times, but I'm struggling here and need your help.

Which is correct for the HTML5 LANG attribute? en-US or en_US?

For example;

<html lang="en-US">

or

<html lang="en_US">

Your opinions would be greatly appreciated

Octa answered 11/8, 2015 at 8:27 Comment(0)
D
8

The spec uses a dash - as a delimiter to specify language-extlang: http://www.w3.org/International/articles/language-tags/ so:

<html lang="en-US">

This is almost always the case when specifying langauge. The exceptions are frameworks like Django they may use an _ instead on the backend.

Decencies answered 11/8, 2015 at 8:30 Comment(0)
I
4

According to BCP 47 (RFC 5646 and RFC 4647) "en-US" seems to be correct.

It refers to the IANA Language Subtag and Language Tag Extensions registries.

I suggest you should refer to the best practices.

Ito answered 11/8, 2015 at 8:38 Comment(0)
G
0

From the spec:

A language tag is composed from a sequence of one or more "subtags", each of which refines or narrows the range of language identified by the overall tag. Subtags, in turn, are a sequence of alphanumeric characters (letters and digits), distinguished and separated from other subtags in a tag by a hyphen ("-", [Unicode] U+002D)

So en-US is correct..

Glycogenesis answered 11/8, 2015 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.