Search code examples
htmllang

Which Language Attribute is Correct?


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


Solution

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