Introduction to Document Type Definitions
A Document Type Definition (DTD) sets forth a group of declarations conforming to a specific markup syntax. These definitions dictate the syntax for SGML or XML applications, notably the markup languages of HTML and XHTML. A DTD outlines the essential “building blocks” of an HTML or XHTML document.
Elements such as
<p> are defined, including how they may be nested to illustrate their parent/child relationships.
Attributes offer additional information about an element, each with an associated value, for example,
Entities are variables used to define common text symbols like
> (representing &, <, and >, respectively).
PCDATA and CDATA
PCDATA refers to Parsed Character Data, which is text parsed by a parser, whereas CDATA is Character Data where the text is not parsed.
The Importance of a DTD
Why Do We Need a DTD?
The Role of DTD in Web Development
Implementing a DTD
How to Use a DTD
A DTD is declared in a webpage using the
DOCTYPE declaration, which is case-sensitive and includes both a public identifier (its name) and a system identifier (a URI to the DTD). Although the
DOCTYPE declaration contains the DTD's Uniform Resource Identifier (URI), browsers typically reference an internal list, using the URI merely as a reference point.
Example of a Correct DOCTYPE Declaration
The W3C website provides a full list of recommended DOCTYPEs, but a subset is particularly recommended for most web pages. These range from HTML 4.01 Strict for those uncomfortable with XHTML to XHTML 1.0 Transitional for beginners, and XHTML 1.0 Strict or XHTML 1.1 for more advanced or purist developers.
Standards-Compliant Web Pages
Producing a web page that complies with web standards starts with a correctly formed DOCTYPE declaration, ensuring that the public and system identifiers are correctly stated. This allows browsers to render the markup and code in standards-compliant mode and enables validators to check the markup and CSS, particularly important for accessibility. The choice of DOCTYPE impacts the allowed elements and attributes, influencing the strictness of presentational markup separation from structure.
Original article “All in the Head: Document Type Definitions” by Karl Dawson, January 2006, https://www.thatstandardsguy.co.uk/ updated by SearchGo in December 2023.
References and Citations
- World Wide Web Consortium (W3C) – For comprehensive standards and guidelines: https://www.w3.org/
- HTML5 Specification – Latest standards and guidelines for HTML5:
- Quirks Mode and Standards Mode – Explanation of browser rendering modes: https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode