What's the best doctype? [closed]
It used to be so that documents with doctypes got standards mode, documents without开发者_JAVA百科 doctypes got quirks mode. But it seems that these days there are some almost-standard modes, different browsers follow different rules etc.
What's the best doctype to use for HTML? Is there any reason not to use the simplest one <!DOCTYPE html>? Most documents don't follow any particular DTD to the letter anyway.
Going forward and into the future, the HTML5 Doctype would be my recommendation.
<!DOCTYPE HTML>
In practice, the HTML validators pay far more attention to a page's doctype than browsers do anyway.
UPDATE: For those commenters that question the statement immediately above, here is my source for that statement: Webkit Blog. It says:
...beware, the validator looks at your doctype instead of the MIME type, unlike browsers.
Also, FWIW, the recommendation of the Webkit people in the above linked blog is to use an HTML 4.01 transitional doctype, served with mime-type text/html and validated as HTML, not XHTML.
What is the simplest you need for the page you are creating?
You should specify which type of webpage you are presenting, so if you are using tables for layouts then HTML 3.1, if using CSS then HTML 4.01.
If you are going to use some of the new features in HTML5, then use that one.
Basically, be specific about what you are doing, to help the browser to render your page in the best way.
精彩评论