DTD

Stands for "Document Type Definition." A DTD defines the structure, elements, and attributes of an XML document. It provides a set of rules that XML files must follow, ensuring consistency and validity across similar documents.

A DTD specifies:

  • What elements (tags) are allowed
  • The order and nesting of elements
  • What attributes elements can have
  • The types of values those attributes may contain

Below is an example DTD for saving automobile data as XML:

<!DOCTYPE automobile [
  <!ENTITY header "Car Details">
  <!ELEMENT make (#PCDATA)>
  <!ELEMENT model (#PCDATA)>
  <!ATTLIST model doors (two | four) #REQUIRED>
  <!ELEMENT year (#PCDATA)>
  <!ELEMENT engine (#PCDATA)>
  <!ATTLIST engine transmission (manual | automatic) #REQUIRED>
]>

In the above DTD:

  1. An entity named header is defined with the value "Car Details."
  2. Elements like <make><model><year>, and <engine> are declared to contain parsed character data (#PCDATA), meaning they accept text.
  3. Attribute lists (ATTLIST) define valid attribute values. For instance, the model element must specify either "two" or "four" for the doors attribute, and the engine element must include a transmission attribute set to either "manual" or "automatic."

This automotive example is a relatively simple Document Type Definition. DTDs used in real-world applications — especially those that support large XML datasets — can span hundreds or thousands of lines. Small DTDs are often included inside XML documents, while large ones are saved as separate files (with a .DTD extension) and referenced via URL. Although newer schema languages like XML Schema (XSD) offer more flexible validation options, DTDs remain the standard way to define XML document structure.

NOTE: HTML 2 through 4.01 (1995-1999) used DTDs to define the allowed tags and attributes of an HTML file. HTML5 abandoned external DTD references and begins each HTML document with <DOCTYPE html>.

Updated May 10, 2025 by Per C.

quizTest Your Knowledge

What is the default MTU size for an Ethernet network connection?

A
512 bytes
0%
B
1500 bytes
0%
C
4 kilobytes
0%
D
12 kilobytes
0%
Correct! Incorrect!     View the MTU definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of DTD on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please use the green citation bar directly below the definition.

Our goal to explain computer terminology in a way that is easy to understand. We strive for accuracy and simplicity with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

TechTerms Newsletter

Improve your technical knowledge with our daily or weekly newsletter! Subscribe today and get new terms and quizzes delivered to your inbox.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.