Declare a DOCTYPE. The DOCTYPE goes before the opening html tag at the top of the page and tells the browser whether the page contains HTML, XHTML, or a mix of both, so that it can correctly interpret the markup. There are three main DOCTYPEs that let the browser know what kind of markup it is dealing with:
Strict:
All markup is XHTML-compliant.
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
Transitional:
This states that the markup is a mix of XHTML and deprecated HTML. Many well-established sites are currently using this one, so their old HTML code can exist happily in the document alongside the XHTML they are now adding.
Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
Frameset:
This is the same as transitional but in this case frames, which are deprecated under XHTML, are OK, too.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”>
It is important to specify a DOCTYPE. Browsers that don’t see a DOCTYPE in the markup assume that the site page was coded for browsers developed long before Web standards. My recommendation is that if you are building a site from scratch, and can therefore avoid deprecated or abandoned tag attributes, such as FONT and COLOR, use the XHTML Strict DOCTYPE listed previously.
When encountering a page without a DOCTYPE, many browsers go into what is known as Quirks mode, a backwards-compatibility feature supported by Mozilla, Internet Explorer 6 for Windows, and Internet Explorer 5 for Macintosh.
In Quirks mode, the browser functions as if it has no knowledge of the modern DOM (document object model) and pretends it has never heard of Web standards. This ability to switch modes depending on the DOCTYPE, or lack thereof, enables browsers to do the best possible job of interpreting the code of both standards- compliant and noncompliant sites.
Note that for some weird reason, the DOCTYPE tag does not need to be closed with a slash and DOCTYPE is always in caps.







0 Comments until now.
Comment!