[html] HTML meta tag for content language

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

This question is related to html internationalization meta-tags

The answer is


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


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)


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


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" />

Examples related to html

Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment

Examples related to internationalization

Best practice multi language website hardcoded string "row three", should use @string resource Android: how to get the current day of the week (Monday, etc...) in the user's language? How to use UTF-8 in resource properties with ResourceBundle HTML meta tag for content language What is the significance of 1/1/1753 in SQL Server? List of All Locales and Their Short Codes? How does internationalization work in JavaScript? PHP function to make slug (URL string) How to force NSLocalizedString to use a specific language

Examples related to meta-tags

Showing Thumbnail for link in WhatsApp || og:image meta-tag doesn't work What is initial scale, user-scalable, minimum-scale, maximum-scale attribute in meta tag? Is it still valid to use IE=edge,chrome=1? Provide an image for WhatsApp link sharing How to add meta tag in JavaScript How do I get the information from a meta tag with JavaScript? What is the attribute property="og:title" inside meta tag? What's the point of 'meta viewport user-scalable=no' in the Google Maps API <meta charset="utf-8"> vs <meta http-equiv="Content-Type"> HTML meta tag for content language