Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Render HTML5 meta charset at first position #98

Merged
merged 1 commit into from
Mar 20, 2017
Merged

Render HTML5 meta charset at first position #98

merged 1 commit into from
Mar 20, 2017

Conversation

wandersonwhcr
Copy link
Contributor

W3C Markup Validation Service currently checks if a "meta charset" is configured at first position, because a HTML5 renderer needs to know what charset to use before the content.

Makes sense.

https://validator.w3.org/
http://stackoverflow.com/questions/18007771/how-do-i-fix-error-a-charset-attribute-on-a-meta-element-found-after-the-first

W3C Markup Validation Service currently checks if a "meta charset" is
configured at first position, because a HTML5 renderer needs to know
what charset to use before the content.
@froschdesign
Copy link
Member

@wandersonwhcr

W3C Markup Validation Service currently checks if a "meta charset" is configured at first position, because a HTML5 renderer needs to know what charset to use before the content.

This description is not correct, because the HTML specification says nothing about "first position". The first 1024 bytes of the document must contain the declaration:

The element containing the character encoding declaration must be serialized completely within the first 1024 bytes of the document.

https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset

You solution doesn't prevent the 1024 bytes problem:

echo $this->headTitle(), $this->headLink(), $this->headScript(), $this->headMeta();

For the headMeta helper alone it could be a solution. And an additional hint in the documentation would be also fine.

@wandersonwhcr
Copy link
Contributor Author

Hello @froschdesign , ty for your notes about it.

BTW, I didn't mention the HTML spec, just only the W3C validator; I know about possible rendering order with headTitle, headLink, headScript and headMeta.

If you think this PR is still usefull, I can add some documentation about it.

Again, ty for your attention.

Cheers.

@weierophinney
Copy link
Member

I think it makes sense; merging for 2.8.2.

@weierophinney weierophinney added this to the 2.8.2 milestone Mar 20, 2017
@weierophinney weierophinney merged commit 407a451 into zendframework:master Mar 20, 2017
weierophinney added a commit that referenced this pull request Mar 20, 2017
Render HTML5 meta charset at first position
weierophinney added a commit that referenced this pull request Mar 20, 2017
weierophinney added a commit that referenced this pull request Mar 20, 2017
weierophinney added a commit that referenced this pull request Mar 20, 2017
@weierophinney
Copy link
Member

Thanks, @wandersonwhcr

@wandersonwhcr
Copy link
Contributor Author

@weierophinney you're welcome 👍

@wandersonwhcr wandersonwhcr deleted the meta-charset-position branch March 20, 2017 18:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants