Architecting and designing : XML schema design : XML history and topics of interest : What is a document type definition (DTD)? : Document type definition (DTD)
  
Document type definition (DTD)
A Document Type Definition (DTD) is a method for explicitly and completely defining the structure of a given XML document. Documents are regarded as having types, just as other objects processed by computers do. The type of a document is composed of its constituent parts and their structure. The definition of a sales report, for example, might be that it consisted of a title and an author, followed by an abstract and a sequence of one or more paragraphs. Anything lacking a title, according to this formal definition, would not formally be a report, and neither would a sequence of paragraphs followed by an abstract, whatever other report-like characteristics these might have for the reader.
If documents are of known types, a special purpose program (called a parser) can be used to process a document claiming to be of a certain type and check that all the elements required for that document type are present and correctly ordered. More importantly, different documents of the same type can be processed in a uniform way. Programs can be written which take advantage of the knowledge encapsulated in the document structure information, and which can thus behave in a more intelligent fashion.
A DTD looks similar to an instance of an XML document but uses Declaration Syntax rather than Instance Syntax. Declarations begin with <! rather than just the open angle bracket, and the way the declarations are formed also differs slightly. A DTD can be part of an XML document, but it is usually a separate document or series of documents. The purpose of a DTD is to constrain:
The elements that can be included in a document
Where elements can appear
The attributes for each element
Until the schema portion of the XML specification is mature, XML developers are using DTDs to provide applications with advance notice of the structures and names that can be used in a specific document type.
Because XML is not a language itself, but rather a system for defining languages, it does not have a universal DTD the way HTML does. Instead, each industry or organization that wants to use XML for data exchange can define its own DTDs. If an organization uses XML to tag documents for internal use only, it can create its own private DTD.
See also
What is a document type definition (DTD)?