joshbuchea / HEAD

A simple guide to HTML <head> elements
https://htmlhead.dev
30k stars 1.92k forks source link

Language Specification in Header #174

Closed kailashvele closed 7 years ago

kailashvele commented 7 years ago

Option to specify the language is missing, without that Chrome cannot suggest the full page translation also the content rendering may face some problem or performance problem as browser will have to identify it (maybe).

willpower232 commented 7 years ago

This interests me as I had not previously considered this scenario.

According to this https://webmasters.stackexchange.com/a/5073 google may well prefer the server to send the header rather than relying on meta data.

Furthermore, MDN suggests that specifying the language on <html> is now the preferred option and the meta tag is obsolete https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta

Excuse me whilst I go and double check I've specified the language everywhere...

scottaohara commented 7 years ago

Hi @kailashvele,

The language for a document should be specified on the html element:

<!doctype html>
<html lang="en">
  <head>
    ...
  </head>

There was a <meta http-equiv="Content-Language" content="en"> declaration that used to belong in the head. However this meta tag has been deprecated.

Setting the lang attribute on the html element, or on content wrapping elements within the body (if the language is different for a section of content than the language set at the document level), is the appropriate way to declare language these days.

kailashvele commented 7 years ago

Sure, I considered it should be the part of document as well or we can add this point in the documentation that Lang meta is deprecated you can put it on html. :)

scottaohara commented 7 years ago

There used to be a section for deprecated tags, but it was becoming more common for people to be making PRs for tags that belonged in the deprecated section, than useful content for the head.

The document was streamlined to only focus on the useful content that belongs in the head of a document, and anything that wasn't considered useful or falls outside of the head wasn't included.

You're right that making people aware of setting an appropriate language is for a document is important. Unfortunately that just falls out of the scope of this project.

kailashvele commented 7 years ago

Oh Okay, sounds a valid reason :)