Are There Any Pros to Use HTML 5 Doctype `<!DOC

2019-07-06 21:18发布

问题:

Are there any pros to use the HTML 5 doctype <!DOCTYPE html>, even if I am not using any new HTML 5 tags? Are there any benefits to replacing the XHTML doctype with the HTML 5 doctype, even if I am not using any new HTML 5 tags?

Can the HTML 5 doctype create problems in terms of functionality if I am using anything XML related with my site, or using HTML 5 for web development with any A-Grade browser? Is it supported in all desktop and mobile browsers?

Or, for right now, is it good to stick with the XHTML Doctype until 2015?

回答1:

Is there any pros to use HTML 5 doctype even if i'm not using any new HTML 5 tag?

Slightly less typing.

That's about it.

I wouldn't use the HTML5 doctype yet. With this doctype you're stating that your document conforms to a specification that is still a moving target. IMO: wait until the spec is finished and the validation process tied down.



回答2:

You may be interested to check out John Resig's blog post on this topic (the founder of jQuery):

What's nice about this new DOCTYPE, especially, is that all current browsers (IE, FF, Opera, Safari) will look at it and switch the content into standards mode - even though they don't implement HTML5. This means that you could start writing your web pages using HTML5 today and have them last for a very, very, long time.

You may also want to check out the following Stack Overflow post (August 2008):

  • Any reason not to start using the HTML 5 doctype?


回答3:

Absolutely. It works in every browser except IE6. There's shorter script declarations. And it's easy to remember.



回答4:

It will surely break at least one old browser out there, so I recommend not using HTML 5 unless your page is actually HTML 5.

Also, XHTML and HTML 5 are not strictly compatible.