Databloc - cpanel web hosting
Call us toll free at 1-888-210-1714

The leading provider of top quality cpanel web hosting services.

Databloc Homepage   Shared Web Hosting Reseller Hosting Domain Registration SSL Certificates

Support

Lots of people get confused by doctypes and how they affect web browsers and how the change the way web pages appear. In this article you will learn about doctypes and their use.

Doctype "Document Type Definition", or sometimes referred to as DTD is exactly what is says, it's defines the document, to define the data types, which is the elements contained in your page. The Doctype tells the browser what a <div> tag means and what its attributes are. Without defining the types, you are leaving the browser free to decide how to define such things itself and it will do the worst thing possible by assuming "quirks mode".

"Quirks" is what older browsers settle into due to an issue with Internet Explorer years ago. The folks at Microsoft misinterpreted the W3C web standards in several ways. For example, all other browser makers like Netscape and Opera understood that margin and padding spacing fell outside the boundaries of a containing element, Microsoft made Internet Explorer put the padding on the inside. Along with other errors, this gave pages written to the standard a "quirky" look in Internet Explorer. This is where the Doctype came in. To fix this problem, browsers looked for a doctype on the first line in every web page.

A proper doctype is REQUIRED on each and every web page to guarantee the best adherence to the standard by ALL browsers.

Which Doctype should I use?

There are three doctypes: strict, transitional and frameset. Frameset - If you are using frames in your code, you should use frameset.

For HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

For XHTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Transitional - Allows coders to use HTML elements that are deprecated, that is, tags that are intended to be dropped from the HTML standard and moved into presentational markup (CSS). If you have an pages that contain tags like <center> or <font> or other presentational markup, you can use the transitional doctype while you "transition" the markup in the page to modern standards. Other than that, there is NO reason to use the transitional doctype.

For HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

For XHTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Strict - Strict means you are coding to the current standard with current elements and have moved your presentational information to a CSS stylesheet. ALL newly created pages should use the strict doctype.

For HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

For XHTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

If you use a correct doctype then the W3C Validator can warn you of errors to prevent any cross browser problems, however, this is not guaranteed and it's always best to check by viewing your web pages in as many browsers as you can. Firefox and Opera are especially helpful in checking compliant code.

Warning: some browsers, IE specifically, look for the doctype on the very first line of the markup. If any characters of any kind preceed the doctype itself, the browser assumes no doctype is present and goes into quirks mode.

The XML Declaration

If you are reading about XHTML, you may have come across a different doctype other that the three listed above:

<?xml version="1.0" encoding="utf-8"?>

This is a XML "Processing Instruction" or PI. XHTML is, after all, XML formulated as HTML so your page can use HTML elements. But it is XML so it must be declared as such.
Web Hosting with cPanelPHP4, PHP5 and PHP6MySQLCGI, PerlEnhanced Frontpage ExtensionsRuby On Rails (ROR)Fantastico Enabled
Shared Web Hosting | Reseller Hosting | Domain Registration | SSL Certificates
Customer Support | Terms of Service | Acceptable Use Policy | About Us | Sitemap