I'm using the html5 doctype for a mobile website.
I normally use the following:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
But, I read that http-equiv is deprecated in html5.
I see that the jquery mobile demos/docs are using (strangely it's not properly formed):
<meta charset="utf-8">
But, I also read on http://www.html-5.com/metatags/index.html (not sure if this is an authority or not) that "The tag should no longer be used because it is supported only for the purpose of migrating from xHTML."
Update
I search SO for a similar question and didn't find anything, but a google search开发者_开发技巧 turned up the following:
<meta charset="utf-8"> vs <meta http-equiv="Content-Type">
Either will pass the w3c validator, I prefer to use meta charset="utf-8" because it's shorter if nothing else.
Both are correct, but this is the preferred way to declare document encoding in HTML5.
<meta charset="utf-8" />
Basically developers ( not me :D ) started to forget quotes....
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />
So browsers become smart to accept the above syntax even though it isn't invalid. In fact the browsers will do some pretty crazy things to determine the doctype(especially IE).
If you look at the above example and you will charset
looks like an attribute, if you delete the remaining attributes...you get
<meta charset="utf-8">
its a 100% backwards compatible.... :D
精彩评论