HTML meta tag for content language

后端 未结 5 1290
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 17:51

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


         


        
相关标签:
5条回答
  • 2020-12-12 18:26

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

    <meta property="og:locale" content="en" />
    
    0 讨论(0)
  • 2020-12-12 18:28

    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.

    0 讨论(0)
  • 2020-12-12 18:33

    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" />
    
    0 讨论(0)
  • 2020-12-12 18:35

    <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">
    
    0 讨论(0)
  • 2020-12-12 18:38

    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)

    0 讨论(0)
提交回复
热议问题