DTD Keywords

Document Type Definition (DTD) ELEMENT Keyword

The ELEMENT keyword defines elements that may be a part of the document and their options or requirements. Each element may or may not require the use of other elements within it. There are three parts of the element definition which include:

  1. Name - The element name.
  2. Specification of beginning and ending tags
  3. Element content.

Ending tag Specifications

This part specifies whether beginning or ending tags are required. The following list explains the possibilities.

  • - - Start and end tags mandatory.
  • - O Omit the end tag if desired.
  • O O Omit the start and end tag if desired.

ELEMENT Content

Content specifies the content of the elements. This uses the word "EMPTY" and special characters combined with names to define content.

EMPTY

The word "EMPTY" designates the element has no content. Here's an example from the HTML 4 transitional DTD:

<!ELEMENT HR - O EMPTY -- horizontal rule -->

Characters

Character meanings:

  • ? - The element may appear once but does not need to appear at all (optional).
  • + - The element must appear one or more times (repeatable and required).
  • - - (One minus sign) The element must not appear.
  • * - The element does not need to appear, but may appear multiple times (optional and repeatable).
  • , - The elements must appear in the order listed (sequential).
  • | - Any one or more of the elements included in the group must exist.
  • & - All the elements included in the group must appear in any order.
  • () - These brackets are placed around a group of elements to set them apart from other elements. You will see many examples of this.

Examples

In the examples below, the names "ENT1", "ENT2", and so forth are used to describe elements:

DTD Contents Page