Forum Moderators: open

Message Too Old, No Replies

!doctype

What purpose does it serve?

         

Filipe

5:00 pm on May 3, 2002 (gmt 0)

10+ Year Member



Whenever I make a new document in ColdFusion Studio or Homesite, it autoinserts

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

at the top of my page. What does this do functionally, and what other variations are there on this?

korkus2000

5:06 pm on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It gives your html a reference to the standards.

html
[w3schools.com...]

xhtml
[w3schools.com...]

rcjordan

5:06 pm on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A valid HTML document declares what version of HTML is used in the document. The document type declaration names the document type definition (DTD) in use for the document

[w3.org...]

topr8

5:06 pm on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



w3c [w3.org]

look under DTD for a full explanation,

pcguru333

5:09 pm on May 3, 2002 (gmt 0)

10+ Year Member



Below is a snippet of info from w3c (http://www.w3.org/TR/xhtml1/#normative).

It explains how XHTML document must be defined (which is what the doc type does for you - defines what type of XHTML you are conforming to)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3.1.1 Strictly Conforming Documents
A Strictly Conforming XHTML Document is a document that requires only the facilities described as mandatory in this specification. Such a document must meet all of the following criteria:

It must validate against one of the three DTDs found in Appendix A.

The root element of the document must be <html>.

The root element of the document must designate the XHTML namespace using the xmlns attribute [XMLNAMES]. The namespace for XHTML is defined to be [w3.org...]

There must be a DOCTYPE declaration in the document prior to the root element. The public identifier included in the DOCTYPE declaration must reference one of the three DTDs found in Appendix A using the respective Formal Public Identifier. The system identifier may be changed to reflect local system conventions.

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"DTD/xhtml1-frameset.dtd">

moonbiter

5:11 pm on May 3, 2002 (gmt 0)

10+ Year Member



It also has a specific purpose in Internet Explorer 6 and Mozilla/Netscape 6, triggering "quirks" mode for backward compatability. The behavior in IE is described here:

[msdn.microsoft.com...]

Filipe

5:14 pm on May 3, 2002 (gmt 0)

10+ Year Member



Thanks guys, esp. Moonbiter, that's exactly what I was looking for.

papabaer

7:34 pm on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some essential <!doctype> reading:
[gutfeldt.ch...]

And a very useful chart:
[gutfeldt.ch...]