Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If I use HTML 5's doctype, what will happen?

Tags:

html

doctype

I have recently been learning about doctypes, and was I wondering what the differences between <!DOCTYPE html> and some of the others were.

I know <!DOCTYPE html> is the HTML5 doctype and it is experimental, but I was wondering what would happen if I used it instead of the other doctypes?

Thanks in advance!!!!

like image 446
Bob Dylan Avatar asked Oct 15 '09 05:10

Bob Dylan


People also ask

What does <! DOCTYPE HTML5.0 mean?

Definition and Usage The declaration is not an HTML tag. It is an "information" to the browser about what document type to expect. In HTML 5, the declaration is simple: <! DOCTYPE html>

Is DOCTYPE necessary for 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.

Are there changes to DOCTYPE for HTML5?

The only thing that such a doctype change will affect is validation. Other than that, the doctype declaration only affects browser mode (quirks / almost standard / standard), and XHTML 1.0 and HTML5 doctype have the same effect in this respect. If you don't use a validator, there is no reason to change.

What will happen if we don't use DOCTYPE?

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.


2 Answers

Basically what will happen is that you'll get your page rendered in a "standards mode".

The only reason why you probably shouldn't use the new DOCTYPE is if you want to use XHTML 1.0 markup and conform to XHTML 1.0.

The downside to using HTML5 now is that the spec can change. This makes it important for you to keep up with the spec as it actively changes.

With that being said, I've already started using the new syntax in my pages. Also it guarantees that your page will last for a very, very, long time.

So go ahead, use it (and learn to love how simple it is).

like image 187
Kredns Avatar answered Oct 23 '22 07:10

Kredns


The HTML5 doctype isn’t experimental. Ian Hickson tested a bunch of browsers, and found that <!DOCTYPE html> worked the same in them as the HTML 4 and XHTML 1 doctypes (i.e. it triggered standards mode).

However, if you use it, then validators will (by default) validate your page as if it’s HTML5, which may not be what you want if you’re actually writing HTML 4. (For example, some elements are getting dropped in HTML5. Using them would show up as an error if you validated your page as HTML5.)

like image 36
Paul D. Waite Avatar answered Oct 23 '22 07:10

Paul D. Waite