82

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">
Michel
  • 490
  • 4
  • 11
byneri
  • 4,050
  • 5
  • 27
  • 28

6 Answers6

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">
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I do something similar on the rare occasions that I work on a multilingual site. – Quentin Dec 11 '10 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 '14 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 : http://www.w3.org/International/questions/qa-http-and-lang – Simon Mourier Sep 15 '14 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.

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
dakab
  • 5,379
  • 9
  • 43
  • 67
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" />
gojeg
  • 169
  • 1
  • 4
  • 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. – Swiss Mister Jun 09 '15 at 09:32
  • Agreeing with Swiss Mister. Useful hint, but you probably don't want to list the current page in a list of "alternates". – HoldOffHunger Sep 10 '16 at 01: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 '17 at 00: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. – Marten Koetsier Apr 28 '17 at 08: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*](https://developers.google.com/search/docs/advanced/crawling/managing-multi-regional-sites) – Fabien Snauwaert Jan 20 '21 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)

zoladp
  • 121
  • 1
  • 6
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/

Mahdi mehrabi
  • 1,486
  • 2
  • 18
  • 21
-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

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85