Search code examples
xhtmlattributesmeta-tagslang

XHTML meta description and keywords with lang attribute


Is it ok to have this kind of meta declarations in the head section of a XHTML document?

<meta name="keywords" lang="en" content="..."/>
<meta name="description" lang="en" content="..."/>
<meta name="keywords" lang="ro" content="..."/>
<meta name="description" lang="ro" content="..."/>
<meta name="keywords" lang="fr" content="..."/>
<meta name="description" lang="fr" content="..."/>

etc

Basically is it good to have all at once, or should I just put two by two depending on what language is selected?

Thank you.


Solution

  • Is it ok to have this kind of meta declarations in the head section of a XHTML document?

    Yes, it's perfectly valid to do so; you can find a similar example in the HTML4 spec on the META element. The XHTML spec additionally suggests that you also add xml:lang when using lang.

    Basically is it good to have all at once, or should I just put two by two depending on what language is selected?

    This is a choice you must make depending on various factors. If you have a large number of languages and it's easy for you to dynamically generate a page with just the selected language, do so because it will save bandwidth. Otherwise, you can leave it as it is. Both ways are correct though.