Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any reason not to start using the HTML 5 doctype? [closed]

Tags:

html

doctype

People also ask

Is it necessary to use DOCTYPE in HTML5?

All HTML need to have a DOCTYPE declared. The DOCTYPE is not actually an element or HTML tag. It lets the browser know how the document should be interpreted, by indicating what version or standard of HTML (or other markup language) is being used.

Will HTML5 work if you do not include <! DOCTYPE HTML in the beginning of your HTML page?

<! DOCTYPE html> // Tells the browser that we are using HTML5. If document type is not mentioned, browser will go to Quirks mode. Quirks mode depends upon the web browser version, If is older version then this will not support HTML5 tags (Example: header tag, footer tag, section tag,...)

What will happen if DOCTYPE is not used in starting HTML document?

The absence of the DOCTYPE or its incorrect usage will force the browser to switch to quirks mode. It means that the browser will do its best to layout the page that is considered to be old or created against web standards.

Do all HTML5 documents require a DOCTYPE?

All HTML documents must start with a <! DOCTYPE> declaration. The declaration is not an HTML tag. It is an "information" to the browser about what document type to expect.


Well consider this:

When serving as text/html, all you need a doctype for is to trigger standards mode. Beyond that, the doctype does nothing as far as browsers are concerned.

When serving as text/html, whether you use XHTML markup or HTML markup, it's treated by browsers as HTML.

So, really it comes down to using the shortest doctype that triggers standards mode (<!DOCTYPE html>) and using HTML markup that produces the correct result in browsers.

The rest is about conforming, validation and markup prerference.

With that said, using <!DOCTYPE html> now and trying to make your markup conform to HTML5 is not a bad idea as long as you stick to stable features that work in browsers now. You wouldn't use anything in HTML4 or XHTML 1.x that doesn't work in browsers, would you?

In other words, you use <!DOCTYPE html> with HTML4-like markup while honoring things that have been clarified in HTML5. HTML5 is about browser compatibility after all.

The downside to using HTML5 now is that the spec can change quite often. This makes it important for you to keep up with the spec as it actively changes. Also http://validator.nu/ might not always be up-to-date, but http://validator.w3.org/ isn't always up-to-date either, so don't let that stop you.

Of course, if you want to use XHTML 1.0 markup and conform to XHTML 1.0, then you shouldn't use <!DOCTYPE html>.

Personally, I always use <!DOCTYPE html> for HTML.


My question to you would be why use it if you don't use any of the new/unsupported features. I'm not saying you couldn't play around with it, but why start building sites with a doctype that offers no benefits and could be supplemented by XHTML5.


I'd say use it and test extensively. Then let us know if it blew your house up or something. :')


Based on the latest IE8 beta, it seems that MS will use the HTML5 doctype as a bypass for the IE8 mode switching quagmire. It seems that the biggest risk with deploying the HTML5 doctype early is that if people publish a lot of IE8-incompatible content with the HTML5 doctype before IE8 ships, MS might get cold feet about making the mode situation simple for HTML5.

Update: This has been voted down, it seems. Quite obviously now that IE8 has shipped, the above consideration no longer applies. And indeed, the situation is not simple with IE8.


The downside for me mainly concerns validation:

  1. Third party validation tools does not always keep up with changing specs, making my favorite tools unreliable.
  2. I prefer to validate against strict doctypes to make sure I have closed all elements. It's an easy way to avoid simple but time consuming nesting errors. With HTML 5 you don't have to close your elements, so there is no way to find unmatched tags.

if you're going to use the doctype, experiment with the features. As long as they don't go into a production site, and you test them thoroughly, have at it.


Consider your audience and your needs. I write pages such as class tests with a target audience of students in my courses who use FireFox 3 in an Ubuntu equipped computer laboratory. I need SVG with MathMl embedded as a foreignObject in the SVG. I use the HTML5 doctype and new HTML5 tags freely.