DTD
A DTD (Document Type Definition) is the structure-definition mechanism of XML 1.0; it is simpler than XSD but limited, and is written in a special (non-XML) syntax.
Purpose
To provide basic structural validation for XML, defining the allowed elements, attributes, and hierarchy.
Mechanism
<!ELEMENT name (content)> declares elements and children, <!ATTLIST> declares attributes, and <!ENTITY> declares entities. There is no type system (strings only) and no namespaces. Before HTML5, HTML used a DTD.
Use cases
- HTML 4.01 / XHTML 1.0 DTDs
- Legacy XML document validation
- SVG 1.1 DTD
- Teaching examples
Examples
- Input
<!ELEMENT name (#PCDATA)>OutputThe name element contains text onlyElement declaration
Common errors
- A DTD cannot express modern constraints (types, namespaces)
- Migrate to XSD or JSON Schema
Related terms
XSD
XSD (XML Schema Definition) is the W3C-standard language for defining XML document structure, describing elements, attributes, and type constraints in XML syntax. GLOSSARY
XML
XML (Extensible Markup Language) is the W3C-standard markup language describing data with a tag tree, supporting namespaces, schema validation, and style transformation. GLOSSARY
JSON Schema
JSON Schema is a vocabulary for describing the structure of JSON documents, defining types, constraints, and validation rules; it is the schema standard for JSON. GLOSSARY