|
|||||||||||||
Choosing proper DOCTYPE declaration (DTD)
What is the DTD, or DOCTYPE?DOCTYPE Declaration, or DTD, is a special HTML document declaration, that tells newer browsers to what version of HTML the developer relied on. The problem is that newer browsers decided to go closer to supporting the W3G standards, and for the backward compatibility they said to all the developers: we render old sites as we did prior, but if you want to signal browsers to render your HTML like W3C asks, please include the following code lines to the beginning of HTML. The browsers, when rendering HTML, should see that if the site is without the declaration, it should be rendered as if the developer made his HTML and CSS compatible with both browsers, while working with older versions. To make your HTML look the same in all browsers declare the doctype: HTML 4.01 - Strict, Transitional, Frameset:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> This is to declare that you intend to use 4.01 compatibility mode. Strict mode tells browser to render HTML in strick compliance mode, i.e. tags that are obsolete in 4.01, or tags from newer versions of HTML are not rendered. The frameset and transitional would work in full compatibility mode, while still supporting newer and older tags (like iframe, font, etc). XHTML 1.0 - Strict, Transitional, Frameset:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Again, when no doctype is declared at all, modern browsers browsers fall to low compliance mode and render your HTML as if they were of older version (reproducing all the rendering bugs that were in their engines), this is the "quirks", or "non-standards" mode. What is the best and right doctype to use?The most right thing to do is to use
Why exactly, and to know the difference between HTML 4.01 and XHTML 1.0 refer to this site.
|
Complete solution:
|
|
|||||||||||