开发者

What's the best doctype? [closed]

开发者 https://www.devze.com 2022-12-08 08:06 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消