Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Language Attribute is Correct?

Tags:

html

lang

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

like image 447
Takuhii Avatar asked Aug 11 '15 08:08

Takuhii


2 Answers

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.

like image 74
Kit Sunde Avatar answered Oct 19 '22 14:10

Kit Sunde


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.

like image 35
Aditya Korti Avatar answered Oct 19 '22 16:10

Aditya Korti