>> English << | česky | Español | По-русски | Français | Italiano | Deutsch | MagyarZVON > Tutorials > DTD Tutorial
>> Example 9 << | Prev | Next | Contents

Description

Attributes are used to associate name-value pairs with elements. Attribute specifications may appear only within start-tags and empty-element tags. The declaration starts with ATTLIST then follows the name of the element the attributes belong to and then follows the definition of the individual attributes.

DTD


An attribute of CDATA type can contain any character if it conforms to well formedness constraints. The required attribute must be always present, the implied attribute is optional:

<!ELEMENT attributes (#PCDATA)>
<!ATTLIST attributes 
      aaa CDATA #REQUIRED
      bbb CDATA #IMPLIED>

Valid documentsTop


CDATA attribute can contain any character conforming to well-formedness constraints:

 <!DOCTYPE attributes SYSTEM "tutorial.dtd">

<attributes aaa="#d1" bbb="*~*">
   Text
</attributes>

The order of attributes is not important:

 <!DOCTYPE attributes SYSTEM "tutorial.dtd">

<attributes bbb="$25" aaa="13%">
   Text
</attributes>

The bbb attribute can be omitted as it is implied:

 <!DOCTYPE attributes SYSTEM "tutorial.dtd">

<attributes aaa="#d1" />

Documents with errorsTop


The aaa attribute is required. Therefore it must be always present.:

 <!DOCTYPE attributes SYSTEM "tutorial.dtd">

<attributes ___ bbb="X24"/>