Document Type Declaration Article Index for
Document
Shopping
Declaration
Website Links For
Document
 

Information About

Document Type Declaration




Despite its name, a Document Type Declaration is not suitable for deducing the type of the document , although apparently it was originally supposed to be.

The HTML Layout Engine s in modern Web Browser s perform DOCTYPE "sniffing" or "switching", wherein the DOCTYPE in a document served as text/html determines a layout mode, such as " Quirks Mode " or "standards mode".


DTDS


Syntax


The general syntax for a Document Type Declaration is:


<!DOCTYPE root-element OR PUBLIC FPI "uri" [
<!-- internal declarations -->
]>


In XML, the root element of the document is the first element in the document (In XHTML, the root element is html - being the first element opened and last closed). The keywords SYSTEM and PUBLIC suggest what kind of DTD it is (one that is on a private system or one that is open to the public). If the "SYSTEM" keyword is chosen, the URI of the DTD may follow; if the PUBLIC keyword is chosen then the declaration must have a FPI (Formal Public Identifier) following it and then the URI of the DTD (the FPI for XHTML 1.1 is "-//W3C//DTD XHTML 1.1//EN").

The last part is called an internal subset which can be used to add/edit entities or add/edit elements. This is optional in XML.

Document Type Declarations are slightly different in SGML, where you may associate the public identifier with the system identifier, as it is in HTML.






Example


The first line of many World Wide Web pages reads as follows:



This Document Type Declaration for XHTML includes by reference a DTD, whose Public Identifier is -//W3C//DTD XHTML 1.0 Transitional//EN and whose system identifier is http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd. An entity resolver may use either identifier for locating the referenced external entity. The root element is declared to be html.


HTML 4.01 DTDs


HTML 4.01 Strict does not allow presentational markup with the argument that Cascading Style Sheets should be used for that instead. This is how the strict doctype looks:

"http://www.w3.org/TR/html4/strict.dtd">

Transitional DTD allows some older elements and attributes that have been Deprecate d:

"http://www.w3.org/TR/html4/loose.dtd">

Also if Frame s are used, to get valid results from the SGML Validator , the frameset doctype is needed, like this:

"http://www.w3.org/TR/html4/frameset.dtd">


XHTML 1.0 DTDs


XHTML 's DTDs are also Strict, Transitional and Frameset.

XHTML Strict DTD is the most strict DTD available: no Deprecated tags are supported and the code must be written correctly.

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML Transitional DTD is like the XHTML Strict DTD, but deprecated tags are allowed. This is the most popular current DTD.

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML Frameset DTD is the only XHTML DTD that supports Frameset. The DTD is below.

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">


XHTML 1.1 DTD


This is the latest DTD that has the stringency of XHTML 1.0 Strict, and it is based upon the module framework and modules defined in Modularization Of XHTML .

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


XHTML Basic DTDs


XHTML Basic 1.0

"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">

XHTML Basic 1.1

"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">


XHTML Mobile Profile DTDs


XHTML Mobile Profile 1.0

"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">

XHTML Mobile Profile 1.1

"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">

XHTML Mobile Profile 1.2

"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">


SEE ALSO



EXTERNAL LINKS