DOCTYPE is a declaration that should appear as the first line in your webpage code. It defines the standard to which your webpage is coded, and provides information to the browser as to how the code should be rendered.
If you created your webpage with a WYSIWYG design tool, and that specific application was the only one you have ever used to edit the webpage, then you don't need to be concerned about the doctype declaration. The webpage design application will automatically provide the correct doctype declaration for its own coding standard.
But if you edited the code manually, or edited the webpage with several different applications, you need to understand doctype declarations and make sure your webpage's doctype matches it's coding standard.
There are two primary types of webpage documents, html and xml. If your webpage was initially designed several years ago, it was probably coded to the HTML 4.0 standard. If it was designed more than several years ago, it may contain code structures that have been deprecated - basically discontinued and possibly not accepted by future browsers.
• Browser developers have been very tolerant of out-of-date html code and even the latest browsers will correctly display pages coded to the html 3 and html 2 standard - as long as you inform them with the proper DOCTYPE declaration.
HTML DOCTYPE's
<!DOCTYPE html>
The HTML 5 doctype was designed to make the DOCTYPE decalration less complicated and it specifies all the latest HTML and CSS for mobile devices (responsive design elements). It also drops more deprecated elements.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The HTML 4.01 transitional doctype supports all attributes of the HTML 4.0 standard and deprecated elements. Use it for webpages that may contain some deprecated html 3 elements. Webmasters like this doctype, and it's still widely used because it allows link targets.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
The HTML 4.01 Strict doctype informs the browser that it doesn't need to support deprecated elements and attributes. Link targets are not allowed and CSS should be used to style all elements. Don't use this doctype with a <frameset>. With a <frameset> use the special doctype declaration shown below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
XHTML DOCTYPE's
The XHTML standard, released in January, 1999 changed the definition of a webpage from an html document to an xml document. This means all webpage code must conform to the rules of xml - including symmetrical nesting of tags and all tags must be closed, even single tag elements must close themselves by including a slash at the end of the tag, ie. <br /> <img src="imagename.gif" />.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The XHTML 1.0 Transitional doctype supports most HTML 4.0 code. Internet Explorer version 6 does not fully support XHTML 1.0, so webmasters have been using some creative work-arounds to compensate for that problem. In order to support the HTML tags used for those work-arounds, webmasters use the XHTML 1.0 Transitional doctype declaration.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Use the XHTML 1.0 Strict doctype if your webpage conforms to xml rules and uses CSS to style all elements. Don't use this doctype with a <frameset>. With a <frameset> use the special doctype declaration shown below.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1.1 DOCTYPE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
The XHTML 1.1 standard defines the modularization of XHTML. Modularization provides a means of extending XHTML to be compatible with a wider range of platforms, such as cellphones and other mobile devices.
Webpage Validators
How do you know which doctype declaration to place at the top of your webpage? Use a Webpage Validator. W3C Markup Validation Service is a free validation service provided by the W3C that checks Web documents for conformance to W3C standards. You can paste or type your code into the text area provided, or you can upload a file you want to check, or you can just enter the URL of the page you want to check.
If your website is many years old, like mine, you will have a lot of work to do in order to meet the HTML 4.0 standard, and you'll be glad browser developers have been very tolerant of out-of-date html code.
More HTML Code:
• How to Use a Meta Redirect
• Create a Meta Tag Slide Show - No Java Script Required
• How to Debug HTML
• Make an HTML Element Editable
• Introduction to HTML
• Use HTML Target Attribute to Specify Where to Open Document
• HTML Editors
• Checkbox Basics
• HTML Bulleted or Unordered List
• Setting the Number of Items Visible in a Select List