Lack of a doctype triggers quirks mode, which is meant only for backwards compatibility for "legacy code" that was created before people started using doctypes. It should pretty much never be used; you should always declare a doctype.
You can continue to use XHTML syntax with this doctype if you wish. As far as CSS goes, there aren't any differences I'm aware of with different doctypes, as long as you have one. Doctypes will however change which attributes and elements are valid and in which context. Use the W3C Validator to test your HTML.
Unfortunately, this means you will be rewriting much of your CSS to work in standards mode. I know it sounds like a chore, but you'll just have to bite the bullet and rewrite it.
Choosing a Doctype
text/html
In a nutshell: Here are simple guidelines for choosing a doctype for a new text/html document:
简而言之:以下是为新text / html文档选择doctype的简单指南:
Standards mode, cutting edge validation
标准模式,前沿验证
This is the right thing to do unless you have a specific reason to avoid it. With this doctype, you can validate new features such as
,
and ARIA. Please be sure to test your page in the latest versions of the top browsers. Standards mode, legacy validation target
这是正确的做法,除非你有特殊的理由要避免它。使用此doctype,您可以验证新功能,例如
This doctype also triggers the standards mode, but lets you stick to legacy validation in case you want to avoid new features or more precise validation of old features. You’d like to use the Standards mode, but you use sliced images in table layouts and don’t want to fix them
此doctype还会触发标准模式,但如果您想要避免使用新功能或更精确地验证旧功能,则可以坚持使用旧版验证。您想使用标准模式,但在表格布局中使用切片图像并且不想修复它们
This gives you the Almost Standards mode. Please note that your layouts based on sliced images in tables are likely to break if you later move to HTML5 (and, hence, the full Standards mode). You willfully want the Quirks mode
这为您提供了几乎标准模式。请注意,如果您稍后转到HTML5(因此,完整的标准模式),基于表格中切片图像的布局可能会中断。你真的想要Quirks模式
No doctype.
Please don’t do this. Willfully designing for the Quirks mode will come and haunt you, your coworkers or your successors in the future—when no one even cares about Windows IE 6 anymore (already no one cares about Netscape 4.x and IE 5). Designing for the Quirks mode is a bad idea. Trust me.
请不要这样做。 Quirks模式的故意设计将会困扰你,你的同事或未来的继任者 - 当没有人关心Windows IE 6时(已经没有人关心Netscape 4.x和IE 5)。设计Quirks模式是个坏主意。相信我。
If you still want to support Windows IE 6, it is better to apply specific hacks for it using conditional comments than to regress other browsers into the Quirks mode.
如果您仍然想要支持Windows IE 6,最好使用条件注释为其应用特定的黑客,而不是将其他浏览器回归到Quirks模式。
I am not recommending any of the XHTML doctypes, because serving XHTML as text/html is considered harmful. If you choose to use an XHTML doctype anyway, please note that the XML declaration makes IE 6 (but not IE 7!) trigger the Quirks mode.
我不推荐任何XHTML文档类型,因为将XHTML作为text / html服务被认为是有害的。如果您仍然选择使用XHTML doctype,请注意XML声明使IE 6(但不是IE 7!)触发Quirks模式。