Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lang attribute from html #1110

Closed
necolas opened this issue Jun 1, 2012 · 25 comments
Closed

Remove lang attribute from html #1110

necolas opened this issue Jun 1, 2012 · 25 comments
Labels

Comments

@necolas
Copy link
Member

necolas commented Jun 1, 2012

This project is used for sites that do not contain English-language content. We shouldn't have this attribute in by default, unless there is something I've overlooked.

@tameraydin
Copy link

If we remove this then we would see a lot of site without lang attribute. I think it helps developers to remember that they should declare a primary language for the site. Maybe to add a reminder comment instead remove?

@necolas
Copy link
Member Author

necolas commented Jun 1, 2012

Few people read those comments. I've seen plenty of sites in the wild with the wrong lang code.

@nautilus7
Copy link

It reminds me to change lang, so keep it please.

@mathiasbynens
Copy link
Member

-1 on removing it just because people are using it wrong.

@SBoudrias
Copy link

I agree with @nautilus7. -1 on removing

@ghost
Copy link

ghost commented Jun 2, 2012

It's called html5 boilerplate for a reason.
-1 for removing.

@necolas
Copy link
Member Author

necolas commented Jun 2, 2012

It reminds me to change lang, so keep it please.

Sorry man, but there are wider considerations than that :)

-1 on removing it just because people are using it wrong.

What I'm concerned about is that this project is resulting in people using it incorrectly. Just like you modify a design when people struggle to interact with your product, you should modify code when the defaults repeatedly allow people to make errors...especially in a project that people look to as a "no surprises" default package.

Seeing a whole bunch of french, german, and spanish websites with lang="en" - including Mickael's french blog! blog.mklog.fr - is something that I consider to be a failing on the project's side rather than the developers.

Have I convinced you that this change should have a positive effect avoid perpetuating non-english language websites that have lang="en" on the root node? I'm worried that the more people use HTML5 Boilerplate for non-english, the more useless and meaningless that attribute will become.

@nimbupani
Copy link
Member

Agreed with @necolas here. People do not change defaults and lang=en is not sadly the best default. Perhaps we could create a checklist task in the node build script that would check for such critical settings? But agreed on removing it from index.html

@mathiasbynens
Copy link
Member

Okay, you convinced me. It’s better to have no lang attribute than to have it with a wrong value.

Can we keep an HTML comment in the “unstripped” source to encourage people to add the lang attribute?

@nimbupani
Copy link
Member

👍 to adding HTML comment to encourage people to add it.

@chenzihui
Copy link

Hey guys, I'm new to this and I'm curious, what are the repercussions of leaving lang=en for websites not in English?

But if it's not the best default to have, then I would agree with @mathiasbynens +1 to having HTML comments to educate / encourage people to add it.

@alrra
Copy link
Member

alrra commented Jun 6, 2012

@chenzihui maybe this will help: Specifying the Human Language for Accessibility :)

@Gavrisimo
Copy link

This sounds reasonable to me so I guess +1

Can we keep an HTML comment in the “unstripped” source to encourage people to add the lang attribute?

@grayghostvisuals
Copy link

Yeah, the lang att commented somewhere would still work. +1 on setting a good example for others

@necolas necolas closed this as completed in 0c52750 Jun 9, 2012
@guybedford
Copy link

It could be possible to set lang="" as an empty attribute, which would serve as a reminder to people while not polluting its usage. In a framework html template, I found myself using this method today allowing for an optional variable.

@alrra
Copy link
Member

alrra commented Dec 1, 2012

@guybedford I think that most of the people that forget to add the lang attribute will also forget to add the value, plus:

lang="..." vs lang=""
If an element contains a language attribute with an empty value, the value of a language attribute higher up the document tree will no longer be applied to the content of that element.

lang="" vs HTTP
If the HTTP header contains a language declaration but the html element uses an empty lang attribute, the UA will not recognize the language declared in the HTTP header.

lang="" vs meta Content-Language
If the meta Content-Language element contains a language declaration but the html element uses an empty lang attribute, the UA will not recognize the language declared in the meta Content-Language element.

xml:lang="" vs HTTP
If the HTTP header contains a language declaration but the html element uses an empty xml:lang attribute, the UA will not recognize the language declared in the HTTP header.

xml:lang="" vs meta Content-Language
If the meta Content-Language element contains a language declaration but the html element uses an empty xml:lang attribute, the UA will not recognize the language declared in the meta Content-Language element.

(from: http://www.w3.org/International/tests/tests-html-css/list-language#emptylang)

Setting the attribute to the empty string indicates that the primary language is unknown.

(from: http://dev.w3.org/html5/spec/global-attributes.html#attr-lang)

@guybedford
Copy link

@alrra thanks for the quick response. Apologies for not looking this up further myself first as well. I'm wondering if any of these would actually be an issue. Since one would normally expect the header and meta methods to be made with an understanding of the HTML template.

But I suppose it is possible to be using a framework or server that sets these properties automatically with the developer unaware of this, and then they would be inadvertently overriding it in their page template.

So yeah it probably does make sense to leave it out entirely.

@aoberoi
Copy link

aoberoi commented Dec 14, 2012

@mathiasbynens suggestion for the comment was not taken, any reason?

@mathiasbynens
Copy link
Member

@aoberoi, the commit that closed this issue added the following comment:

<!-- Consider specifying the language of your content by adding the `lang` attribute to <html> -->

Later all comments were removed from the HTML.

@necolas
Copy link
Member Author

necolas commented Dec 14, 2012

It looks like this nugget was unintentionally not ported to the bundled docs. We could create an issue/patch for this.

@Ganginator
Copy link

I would add it without the en, so lang="", and then comment that the proper attribute should be added.

AD7six referenced this issue in FriendsOfCake/crud Aug 19, 2013
drublic added a commit that referenced this issue Dec 15, 2013
We don't set a default lang-attribute on <html> due to the
discussion in #1110. This commit adds a note about how to set it.

Closes #1483.
drublic added a commit that referenced this issue Dec 20, 2013
We don't set a default `lang` attribute on `<html>` due to the
discussion in #1110. This commit adds a note about how to set it.

Close #1483.
kcmckell pushed a commit to kcmckell/html5-boilerplate that referenced this issue Feb 25, 2014
We don't set a default `lang` attribute on `<html>` due to the
discussion in h5bp#1110. This commit adds a note about how to set it.

Close h5bp#1483.
drublic added a commit that referenced this issue Mar 20, 2014
We don't set a default `lang` attribute on `<html>` due to the
discussion in #1110. This commit adds a note about how to set it.

Close #1483.
@anubhavshah
Copy link

Shocked that you guys removed the tag! What else is missing!!!? atleast place a boilerplate with comments as a secondary option so i can fill in the blanks! This way it is hidden and does not catch any attention.

@TheDutchCoder
Copy link

It's unfortunate this happened. Having no attribute will most likely lead to many sites missing any kind of language indication.

The W3C has the following to say:

Always use a language attribute on the html tag to declare the default language of the text in the page.
Source: https://www.w3.org/International/questions/qa-html-language-declarations

If we go this way, then please remove the following items for the exact same reason:

  1. meta charset (this is dependent on client <-> server anyway)
  2. meta description (hell, Google even recommends not using it at all, if you can't provide a 100% unique description)

Whatever happened to providing a good "starting point" for people? Isn't that the purpose of the boilerplate? Shouldn't we try to give people a really good template that they can tailor to their own needs?

@anubhavshah
Copy link

necolas argues above: "What I'm concerned about is that this project is resulting in people using it incorrectly. "

But leaving it out and missing still remains incorrect! In fact a template is meant to do just the opposite. Otherwise just create a blank .html page!!

Its a good thing i had an older copy of the paul irish boiler plate laying around.

@roblarsen
Copy link
Member

Its a good thing i had an older copy of the paul irish boiler plate laying around.

I hate that I will have to pass on the opportunity here to create a "paul irish boiler plate" parody site (Need to create a new Paul Irish? Get started in five minutes with Paul Irish Boilerplate!)

alrra added a commit that referenced this issue May 13, 2014
In the past we decided¹ to remove the `lang` attribute due to the fact
that developers were often forgetting to update its value. This change
turned out not to be the best solution because some of the users:

 * didn't read the documentation, and thus, they found the absence
   of the `lang` attribute confusing, or didn't even knew they had
   to add it

 * didn't notice the absence of the `lang` attribute, and thus, forgot
   to include it (expecting it to be there)

To make things more clearer and to remind users that they need to
specify the primary language of the document, this commit reintroduces
the `lang` attribute, while leaving its value to `""`.

Using `lang=""` has the exact same effect as not specifying the `lang`
attribute at all, in both cases the language being treated as unknown².

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

¹ #1110
² From WHATWG (http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#attr-lang):

  "To determine the language of a node, user agents must look at the
   nearest ancestor element (including the element itself if the node
   is an element) that has a lang attribute in the XML namespace set
   or is an HTML element and has a lang in no namespace attribute set.
   That attribute specifies the language of the node (regardless of
   its value).

   If both the lang attribute in no namespace and the lang attribute
   in the XML namespace are set on an element, user agents must use
   the lang attribute in the XML namespace, and the lang attribute in
   no namespace must be ignored for the purposes of determining the
   element's language.

   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.

   If the resulting value is not a recognized language tag, then it
   must be treated as an unknown language having the given language tag,
   distinct from all other languages."

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Close #1542.
alrra added a commit that referenced this issue May 13, 2014
In the past we decided¹ to remove the `lang` attribute due to the fact
that developers were often forgetting to update its value. This change
turned out not to be the best solution because some of the users:

 * didn't read the documentation, and thus, they found the absence
   of the `lang` attribute confusing, or didn't even knew they had
   to add it

 * didn't notice the absence of the `lang` attribute, and thus, forgot
   to include it (expecting it to be there)

To make things more clearer and to remind users that they need to
specify the primary language of the document, this commit reintroduces
the `lang` attribute, while leaving its value to `""`.

Using `lang=""` has the exact same effect as not specifying the `lang`
attribute at all, in both cases the language being treated as unknown².

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

¹ #1110
² From WHATWG (http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#attr-lang):

  "To determine the language of a node, user agents must look at the
   nearest ancestor element (including the element itself if the node
   is an element) that has a lang attribute in the XML namespace set
   or is an HTML element and has a lang in no namespace attribute set.
   That attribute specifies the language of the node (regardless of
   its value).

   If both the lang attribute in no namespace and the lang attribute
   in the XML namespace are set on an element, user agents must use
   the lang attribute in the XML namespace, and the lang attribute in
   no namespace must be ignored for the purposes of determining the
   element's language.

   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.

   If the resulting value is not a recognized language tag, then it
   must be treated as an unknown language having the given language tag,
   distinct from all other languages."

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Close #1542.
alrra added a commit to use-init/init that referenced this issue May 17, 2014
In the past we decided¹ to remove the `lang` attribute due to the fact
that developers were often forgetting to update its value. This change
turned out not to be the best solution because some of the users:

 * didn't read the documentation, and thus, they found the absence
   of the `lang` attribute confusing, or didn't even knew they had
   to add it

 * didn't notice the absence of the `lang` attribute, and thus, forgot
   to include it (expecting it to be there)

To make things more clearer and to remind users that they need to
specify the primary language of the document, this commit reintroduces
the `lang` attribute, while leaving its value to `""`.

Using `lang=""` has the exact same effect as not specifying the `lang`
attribute at all, in both cases the language being treated as unknown².

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

¹ h5bp/html5-boilerplate#1110
² From WHATWG (http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#attr-lang):

  "To determine the language of a node, user agents must look at the
   nearest ancestor element (including the element itself if the node
   is an element) that has a lang attribute in the XML namespace set
   or is an HTML element and has a lang in no namespace attribute set.
   That attribute specifies the language of the node (regardless of
   its value).

   If both the lang attribute in no namespace and the lang attribute
   in the XML namespace are set on an element, user agents must use
   the lang attribute in the XML namespace, and the lang attribute in
   no namespace must be ignored for the purposes of determining the
   element's language.

   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.

   If the resulting value is not a recognized language tag, then it
   must be treated as an unknown language having the given language tag,
   distinct from all other languages."

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Ref: h5bp/html5-boilerplate#1542.
eleanor-byhook pushed a commit to eleanor-byhook/html5-boilerplate that referenced this issue Feb 29, 2016
In the past we decided¹ to remove the `lang` attribute due to the fact
that developers were often forgetting to update its value. This change
turned out not to be the best solution because some of the users:

 * didn't read the documentation, and thus, they found the absence
   of the `lang` attribute confusing, or didn't even knew they had
   to add it

 * didn't notice the absence of the `lang` attribute, and thus, forgot
   to include it (expecting it to be there)

To make things more clearer and to remind users that they need to
specify the primary language of the document, this commit reintroduces
the `lang` attribute, while leaving its value to `""`.

Using `lang=""` has the exact same effect as not specifying the `lang`
attribute at all, in both cases the language being treated as unknown².

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

¹ h5bp/html5-boilerplate#1110
² From WHATWG (http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#attr-lang):

  "To determine the language of a node, user agents must look at the
   nearest ancestor element (including the element itself if the node
   is an element) that has a lang attribute in the XML namespace set
   or is an HTML element and has a lang in no namespace attribute set.
   That attribute specifies the language of the node (regardless of
   its value).

   If both the lang attribute in no namespace and the lang attribute
   in the XML namespace are set on an element, user agents must use
   the lang attribute in the XML namespace, and the lang attribute in
   no namespace must be ignored for the purposes of determining the
   element's language.

   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.

   If the resulting value is not a recognized language tag, then it
   must be treated as an unknown language having the given language tag,
   distinct from all other languages."

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Close h5bp/html5-boilerplate#1542.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests