Pergunta

If I don't specify a value in the lang attribute of the html tag, what default value does it take? Is it 'en'?

Foi útil?

Solução

http://www.w3.org/TR/html401/struct/dirlang.html

The default value of this attribute is unknown.

Outras dicas

The HTML5 spec goes into a bit more detail than HTML4.01:

If neither the node nor any of the node's ancestors, including the root element, have either attribute set, but there is a pragma-set default language set, then that is the language of the node. If there is no pragma-set default language set, then language information from a higher-level protocol (such as HTTP), if any, must be used as the final fallback language instead. In the absence of any such language information, and in cases where the higher-level protocol reports multiple languages, the language of the node is unknown, and the corresponding language tag is the empty string.

So to summarise that, the lang of a node is determined by:

  • The xml:lang attribute value of the node or an ancestor (in this case we're talking about the root node so there are no ancestors)

  • The lang attribute value of the node or an ancestor

  • The pragma-set default language

  • HTTP headers (or details from some other protocol if not HTTP)

  • If none of the above, then the value is unknown

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top