What is a DTD (Document Type Definition) in XML?

The most current version as of .

A Document Type Definition (DTD) defines the structure of an XML document. When we are talking about structure, we are asking for the following questions:

  • Which elements are allowed?

  • Which elements are required?

  • Which values are allowed for each element?

  • Which nesting of elements is allowed?

  • Which attributes are allowed?

  • Which attributes are required?

  • Which values are allowed for each attribute?

A Document Type Definition provides answers to these questions by defining the answers as a set of rules.

To link a Document Type Definition to a document, we have to use a Document Type Declaration first.
— David Wolf