Page MenuHomePhabricator

Meta tags are better placed first in the head tag.
Closed, DeclinedPublic

Description

Meta tags are better placed first in the head tag.
Would be better placed at the top indicate the character encoding meta tag of it all.

Google, Yahoo! like many websites, to do so.

IE is, when the advent of non-ASCII text, which after the meta tags may be ignored. The current order is similar to what has plagued the Japanese readers in the past.


Version: unspecified
Severity: normal

Details

Reference
bz27843

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:32 PM
bzimport set Reference to bz27843.
bzimport added a subscriber: Unknown Object (MLST).

Do you mean placing <meta> tags before the <title> one?

raising importance since it seems to be a bug.

(In reply to comment #1)

Do you mean placing <meta> tags before the <title> one?

Yes. This happens as a result.

As of 1.17 meta tags are the top-most in the <head> (above any <link> and <script>), except for <title> which is still the first one.

Just trying to clarify since I'm a little confused:

Frozen-mikan, you want the <title> tag moved below the <meta> tags?

Umm, why does this matter?

<meta charset="utf-8"> tags should be ignored by browsers because the http headers take precedence. (Or at least that was the impression I had). So it shouldn't matter how close to the beginning of the document they are. If for some weird reason the charset wasn't specified by the HTTP header, it will still work, it will just take slightly longer to determine the charset (probably its not significant enough to care).

(the position of the other meta tags don't really matter)

I should look more carefully.
I found the following sentences. Please refer to.

http://www.w3.org/TR/1999/REC-html401-19991224/charset.html
5.2.2 Specifying the character encoding

The META declaration must only be used when the character encoding is organized such that ASCII-valued bytes stand for ASCII characters (at least until the META element is parsed). META declarations should appear as early as possible in the HEAD element.

I'm sorry. This is a repost.

I should look more carefully.
I found the following sentences. Please refer to.


http://www.w3.org/TR/1999/REC-html401-19991224/charset.html
5.2.2 Specifying the character encoding

The META declaration must only be used when the character encoding is organized such that ASCII-valued bytes stand for ASCII characters (at least until the META element is parsed). META declarations should appear as early as possible in the HEAD element.

I was just checking to see if this was something that would be trivial to do or not, and it appears to already be done.(for the meta charset tags, the other meta tags there really is no point, unless for maybe something like x-ua-compatible, but we don't send that)

(In reply to comment #8)
[..]


http://www.w3.org/TR/1999/REC-html401-19991224/charset.html
5.2.2 Specifying the character encoding

The META declaration must only be used when the character encoding is organized
such that ASCII-valued bytes stand for ASCII characters (at least until the
META element is parsed). META declarations should appear as early as possible

in the HEAD element.

The html5 spec is probably better for what happens in practise ( http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#determining-the-character-encoding ), however both say that the http headers take precedence.

But anyways, back to the point. The meta tag is first in the head if we're in html5 mode ($wgHtml5=true) (which isn't true on wikipedia, but take a look at http://test.wikipedia.org which does have it true)

Do the placement of meta tags on the test.wikipedia.org match your expectations? If so I'd recommend wontfixing this because its mostly a cosmetic change (as far as i am aware, meta charset tags are ignored if an http content-type header is specified, which is it for 'pedia) and we're going to be switching to html5 mode sooner or later.

EN.WP.ST47 wrote:

Wontfixing per Bawolff. The current configuration in trunk appears to be correct, as attested by test.wikipedia.org, where the meta tag is the first element within the head element. This is not true on en.wikipedia because $wgHtml5 != true, however the UTF-8 tag is the second element, only after title, and of course HTTP headers take precedence before then. There is never a situation where we are unable to specify UTF-8 encoding 'in time'. As the original commentor has not amended this post for four months, I'm closing this wontfix, with the hope that if there is still an issue with the meta element being too late where the $wgHtml5 != true, then a new bug can be opened with an example of the problem.

HTTP Headers don't apply when the html doc has been saved to a machine. When that happens the meta tag IS used to determine the charset, and if it's located after the <title> than any UTF-8 in it breaks. I've had that issue before myself when building things.