# XML - Document Type (Definition|Declaration) (DTD)

Document Type Definition (DTD) is a grammar (language) that defines the schema (ie data structure) of an XML document.

It

## Syntax

The syntax is a set of markup declarations that define a document type for SGML-family markup languages (SGML, XML, HTML).

DTDs were a precursor to XML schemas and have a similar function, although different capabilities.

A DTD can be declared:

• inline inside an XML document,
• or as an external reference.

The document type declaration can point to an external subset (a special kind of external entity) containing:

• markup declarations,
• or can contain the markup declarations directly in an internal subset,
• or can do both.

The DTD for a document consists of both subsets taken together.

DTD are context-free grammars