A Document Type Definition (DTD) defines the legal structure and elements of an XML document. It can be declared inline within an XML file or referenced externally. A DTD is useful for ensuring data validity, enabling data sharing through standardization, and verifying an application's own data. Elements are declared in a DTD using tags that specify things like element content, occurrence, and sequence. DTDs can be internal, contained within the XML file, or external, referenced from an outside file.