Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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")?

share|improve this question
1  
If you are using HTML5 then use 2nd option -- the 1st one is now deprecated. –  LazyOne Sep 15 '11 at 9:23
add comment

2 Answers 2

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.

share|improve this answer
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 9: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
add comment

HTML 4 and below:

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

HTML 5 +

<html lang="en-us">
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.