Webpage DOCTYPE Declarations Explained
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 interpreted.
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.
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.
<!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">