# Document type definitions (DTDs) - overview

A document type definition (DTD) provides you with the means to validate XML files against a set of rules. When you create a DTD file, you can specify rules that control the structure of any XML files that reference the DTD file.

A DTD can contain declarations that define elements, attributes, notations, and entities for any XML files that reference the DTD file. It also establishes constraints for how each element, attribute, notation, and entity can be used within any of the XML files that reference the DTD file.

To be considered a valid XML file, the document must be accompanied by a DTD (or an XML schema), and conform to all of the declarations in the DTD (or XML schema).

Certain XML parsers have the ability to read DTDs and check to see if the XML file it is reading follows all of those rules. While the parser is reading the XML file, it will check each line to be sure that it conforms to the rules that are laid out in the DTD file. If there is a problem, the parser generates an error and points to where the error occurs in the XML file. This kind of parser is called a validating parser because it validates the content of the XML file against the DTD.

Related tasks
Validating DTDs