Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are all the new HTML document types in VS 2012 RC?

I just installed VS 2012 RC and in the HTML toolbar dropdown it has a bunch of new options:

  • DOCTYPE: HTML5
  • HTML5
  • XHTML5

What's the difference between the two HTML5 options? I thought the recommendation for HTML5 was not to specify a DOCTYPE, so the first option is kinda like "would you like some caffeine with that decaf?"

I was pretty sure that W3C abandoned XHTML in favor of evolving HTML, so what's this new XHTML5 option? Update: seems like Wikipedia had an answer for that.

Thanks in advance!

Update: posted a new question for the unanswered bits.

PS: I am not looking for an explanation of the purpose of the dropdown, but rather an explanation of what the difference is between choosing "DOCTYPE:HTML5" and "HTML5".

like image 675
Morten Mertner Avatar asked Jun 02 '12 15:06

Morten Mertner


2 Answers

Regarding the HTML5 vs. DOCTYPE:HTML5 question, here's what I've observed while using VS 2012 RTM:

The DOCTYPE:{value} option tells VS to examine your page and attempt to figure out from the DOCTYPE and html tags what level of validation to apply. For example, if I create a page that begins as follows:

<!DOCTYPE html>
<html>
...

then the DOCTYPE:{value} option becomes DOCTYPE: HTML5. If, however, my page starts like this:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
...

then it becomes DOCTYPE: XHTML5.

The options that don't have the DOCTYPE: prefix force VS to use the selected level of validation regardless of what the structure/content of your page might suggest.

like image 137
Brandon W. Avatar answered Sep 23 '22 02:09

Brandon W.


XHTML 5.0, usually written XHTML5, means HTML5 in XHTML serialization. Reference: HTML vs XHTML in the W3C HTML5 draft. So it’s HTML5 written using XML-conformant markup. Yes, the name “XHTML5” is odd and confusing, but it was probably selected for its assumed coolness factor.

All HTML5 drafts require the use of DOCTYPE preamble. See e.g. The DOCTYPE in W3C HTML5 draft. It’s not really a document type declaration even formally (there is no DTD for HTML5, and my attempts at writing one suggest that it would be rather problematic). Rather, it’s just a magic string that is to be used to make browsers apply “standards mode” vs. “quirks mode”. And it does this job well.

To see the difference between “DOCTYPE:HTML5” and “HTML5”, check out their effects on the source code of the result. My bet is that the latter mean HTML5 without DOCTYPE preamble, which is illogical, as HTML5 requires the preamble. If this is the case, “HTML5” throws browsers to “quirks mode”, which is normally bad for any new page, but often necessary for old pages if one wants to avoid major rewrite.

like image 24
Jukka K. Korpela Avatar answered Sep 23 '22 02:09

Jukka K. Korpela