Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

Doc Type Declaration

Does it have to be included



12:22 am on Jun 15, 2003 (gmt 0)

10+ Year Member

I have pages that were written without a beginning doc type declaration. Most validators proceed without producing an error, but some highlight an error stating that the doc type declaration is a must.
What up with this?


8:16 am on Jun 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

A!DOCTYPE tells a browser unambiguously what variant of HTML or XHTML you are using.

Without it, each browser may interpret some tags differently, leading to a rendering that is more varied between browsers than you'd want.

Without it, many browsers will drop into "quirks" mode -- meaning they'll assume you've coded to match their bugs. If you've actually written clean, validated code chances are this means they've mis-interpreted some of your code.

With it, you aren't guaranteed that browsers won't exhibit bugs -- after all, they all have them, but you are better assured that the page will render correctly across a wide range of browsers.

Some more information at:



8:47 am on Jun 15, 2003 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to WebmasterWorld, Michaeldd.

You certainly CAN have pages with no DTD, the web is full of them. But for a validator to do anything more than a surface check for unclosed tags and bad nesting, it is going to need the DTD.

Speaking personally, validating to a full DTD has taught me a lot - in areas where I thought I already had it nailed.

I also thought this might be a good place to give the link to the W3C's list of valid DTDs [w3.org]. Finally all gathered together in one place. And that place is the source of the HTML standards, so it's the right place to check.


1:28 pm on Jun 15, 2003 (gmt 0)

10+ Year Member

Thanks for the replys...I'm adding DTD to my pages now.



1:52 am on Jun 18, 2003 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

If you want to check your pages without DTDs then try [validator.w3.org...] as that has selector boxes that allow you to set the !DOCTYPE and the Character Encoding for the page without needing it actually on the page.

However, long term, you should aim to add these elements to your code on every page.

You might also want to consider what else you put in the header. For most people, code on each page begins something like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title> Your Title Here </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="EN-GB">
<meta name="Keywords" content=" your, keyword, list, here ">
<meta name="Description" content=" Your Description Here. ">
<meta name="MSSmartTagsPreventParsing" content="TRUE">

Code within the page:

I use: <a href="somepage.html" title="some text here"></a> for links.

I use <img src="somefile.png" alt="some text"> for images.

Headings are done with <hx></hx> tags, properly used from <h1></h1> downwards.

[edited by: g1smd at 2:11 am (utc) on June 18, 2003]


1:57 am on Jun 18, 2003 (gmt 0)

10+ Year Member

> Without it, many browsers will drop into "quirks" mode...

Never heard it put that way before - I like it. ;-)


Featured Threads

Hot Threads This Week

Hot Threads This Month