5

There seems to be two ways to specify the language of a page:

<meta http-equiv="Content-Language" content="en-us">

and

<html lang="en-us">

Which one is the preferred way? I know I could just add both tags but I'd rather not have duplicate content.

Also do both methods use the same locale format (i.e. "en-us" and not "en_US")?

laurent
  • 320
  • 3
  • 11

2 Answers2

5

The second one is the preferred way. http://www.w3.org/TR/html5/semantics.html The first one is "non-conforming". I couldn't find an exact definition of what that means, but I think it means, "it may work, but you can't rely on it".

They both use the format defined in BCP47, which uses a dash, not an underscore.

paulmorriss
  • 15,371
  • 1
  • 38
  • 58
  • 1
    Actually, HTML4(and XHTML) uses RFC1766 for language formats. I don't have the inclination right now to see if/how different those really are, but adding for the sake of the technical note. – Su' Sep 15 '11 at 09:33
  • 1
    It should also be noted that Google actually ignores your language specification and instead auto-detects the language. See answer here from a Google employee. – DisgruntledGoat Sep 20 '11 at 19:40
3

HTML 4 and below:

<meta http-equiv="Content-Language" content="en-us">

HTML 5 +

<html lang="en-us">
David K.
  • 2,771
  • 16
  • 28