81

What is the difference between the following two HTML meta tags, for specifying spanish web page content:

<meta name="language" content="Spanish">

and

<meta http-equiv="content-language" content="es">
1

6 Answers 6

127

<meta name="language" content="Spanish">

This isn't defined in any specification (including the HTML5 draft)

<meta http-equiv="content-language" content="es">

This is a poor man's version of a real HTTP header and should really be expressed in the headers. For example:

Content-language: es
Content-type: text/html;charset=UTF-8

It says that the document is intended for Spanish language speakers (it doesn't, however mean the document is written in Spanish; it could, for example, be written in English as part of a language course for Spanish speakers).

From the spec:

The Content-Language entity-header field describes the natural language(s) of the intended audience for the enclosed entity. Note that this might not be equivalent to all the languages used within the entity-body.

If you want to state that a document is written in Spanish then use:

<html lang="es">
3
  • I do something similar on the rare occasions that I work on a multilingual site.
    – Quentin
    Dec 11, 2010 at 17:30
  • 23
    This is not poor man's version of real HTTP header... If HTML document is opened from disk or embedded in mail message, then there will be no HTTP header. For this reason meta http-equiv exists and should be set along with HTTP headers. Too bad there are two places where you can specify language/encoding and that there is no clear solution from W3C/IETF.
    – mip
    Feb 21, 2014 at 12:15
  • 2
    Speaking of standards, here is a pretty recent publication from W3C named "HTTP headers, meta elements and language information" that confirms this answer, available here : w3.org/International/questions/qa-http-and-lang Sep 15, 2014 at 13:41
49

You asked for differences, but you can’t quite compare those two.

Note that <meta http-equiv="content-language" content="es"> is obsolete and removed in HTML5. It was used to specify “a document-wide default language”, with its http-equiv attribute making it a pragma directive (which simulates an HTTP response header like Content-Language that hasn’t been sent from the server, since it cannot override a real one).

Regarding <meta name="language" content="Spanish">, you hardly find any reliable information. It’s non-standard and was probably invented as a SEO makeshift.

However, the HTML5 W3C Recommendation encourages authors to use the lang attribute on html root elements (attribute values must be valid BCP 47 language tags):

<!DOCTYPE html>
<html lang="es-ES">
    <head>
        …

Anyway, if you want to specify the content language to instruct search engine robots, you should consider this quote from Google Search Console Help on multilingual sites:

Google uses only the visible content of your page to determine its language. We don’t use any code-level language information such as lang attributes.

1
  • 2
    Your google quote was very meaningful for me, thank you.
    – Anoyz
    Jun 4, 2020 at 16:43
16

Google recommends to use hreflang, read more info

Examples:

<link rel="alternate" href="http://example.com/en-ie" hreflang="en-ie" />
<link rel="alternate" href="http://example.com/en-ca" hreflang="en-ca" />
<link rel="alternate" href="http://example.com/en-au" hreflang="en-au" />
<link rel="alternate" href="http://example.com/en" hreflang="en" />
5
  • 13
    I like this hint, but it is not related to the OP. This is to indicate to crawlers where alternative versions of the current page can be found. It does not indicate the language of the current page. Jun 9, 2015 at 9:32
  • Agreeing with Swiss Mister. Useful hint, but you probably don't want to list the current page in a list of "alternates". Sep 10, 2016 at 1:06
  • 2
    @SwissMister @HoldOffHunger the page that have a list of "alternates" should have the current page alternate on top of this list of alternate tags. if all pages have the same content for another country or in an other language it would be good to tell search engines about the alternate pages as it will learn search engines where your content should be shown in search results, for example a page with en-ca and a page with nl-nl, the en-ca will included to the search results in Canada, the page with alternate nl-nl can be found in the results for the Netherlands..
    – jagb
    Apr 25, 2017 at 0:09
  • The google-link indeed mentions that an alternate tag for the current language should be added, but it does not seem to necessarily be at the top. Order seems not important. Apr 28, 2017 at 8:39
  • 1
    It's worth noting that Google also says "Make sure the page language is obvious Google uses the visible content of your page to determine its language. We don't use any code-level language information such as lang attributes, or the URL. You can help Google determine the language correctly by using a single language for content and navigation on each page, and by avoiding side-by-side translations." (in Managing multi-regional and multilingual sites Jan 20, 2021 at 20:18
6

Html5 also recommend to use <html lang="es-ES"> The small letter lang tag only specifies: language code The large letter specifies: country code

This is really useful for ie.Chrome, when the browser is proposing to translate web content(ie google translate)

3

another language meta tag is og:locale and you can define og:locale meta tag for social media

<meta property="og:locale" content="en" />

you can read about og tags in https://ogp.me/

1
  • You should elaborate, you do not mention anything about what it does. ogp.me Feb 12, 2021 at 15:54
-1

As a complement to other answers note that you can also put the lang attribute on various HTML tags inside a page. For example to give a hint to the spellchecker that the input text should be in english:

<input ... spellcheck="true" lang="en"> ...

See: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang

0

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