Quackit Logo

DTD Attributes

Just as you need to define all elements in your DTD, you also need to define any attributes they use. You use the <!ATTLIST> declaration to define attributes in your DTD.

Syntax

You use a single <!ATTLIST> declaration to declare all attributes for a given element. In other words, for each element (that contains attributes), you only need one <!ATTLIST> declaration.

The <!ATTLIST> declaration has the following syntax:

<!ATTLIST element_name
  attribute_name TYPE DEFAULT_VALUE
  attribute_name TYPE DEFAULT_VALUE
  attribute_name TYPE DEFAULT_VALUE
  ...>

Here, element_name refers to the element that you're defining attributes for, attribute_name is the name of the attribute that you're declaring, TYPE is the attribute type, and DEFAULT_VALUE is it's default value.

Example

<!ATTLIST tutorial
  published CDATA "No">

Here, we are defining an attribute called "published" for the "tutorial" element. The attribute's type is CDATA and it's default value is "No".

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
                     
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!