![]() |
HTML & CSS Resources
|
What DTD/DocType should I use?
There are currently four standards in use: HTML 4.01, XHTML 1.0, XHTML 1.1 and HTML5. All of these require a different DTD to tell the browser how to render the page. If you want to use HTML 4.01 or XHTML 1.0, there are three "flavours" of DTD: Strict, Transitional and Frameset. Strict DTDs should be used for all new documents. The browser will render everything in Standards Mode, the most reliable and up-to-date version. Transitional DTDs should be used only when transferring from old versions of HTML. This is highly unlikely, and should be avoided in most circumstances. It forces the browser to guess at what the code means, using a "quirks" mode which renders the document as though it were written over a decade ago. Frameset DTDs allow frame content; this is highly discouraged and should also be avoided. For HTML 4.01: Strict: Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"For XHTML 1.0: Strict: Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"For XHTML 1.1: XHTML 1.1 only has one DTD, but the document must be served as under the MIME types application/xhtml+xml or application/xml. If you do not know what this means, do not use it. Because of this requirement, XHTML 1.1 is not widely used. You may use this DTD:Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"For HTML 5: HTML 5 is currently under development, but some elements have gained support in the most modern browsers. If you wish to use HTML5 and understand the major differences between that and the more-prevalent HTML 4.01, you may use this DTD: Code:
<!DOCTYPE html> |
Testing in Browsers and X-UA-Compatible
In order to ensure maximum compatibility, you should test in as many browsers as possible. Here are the most common ones of each rendering engine: Trident
Gecko WebKit Presto Layout engines of the same type will almost always render the same; it should not be necessary to test in every single version, apart from in Internet Explorer. X-UA-Compatible Internet Explorer can also be forced to always render in IE7 mode by using the X-UA-Compatible header. The easiest way to do this is by including it in a meta element in your document's head:Code:
<meta http-equiv="X-UA-Compatible" content="IE=7"> |
HTML & CSS Official Documentation and Validation
W3C validators W3C specifications: HTML
CSS CSS 1:
Other CSS related documents from W3C: |
|
| All times are GMT +1. The time now is 04:00 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.