Attributes — Overview
Elements such as sections, titles, paragraphs, and lists make up the basic structure of a document. An attribute further defines an element. Attribute values define each element of the same type, making them distinct from one another. Until you become more familiar with elements and attributes, think of an element as a noun and the attribute as an adjective. For example:
Table 18. Example Element Attributes and Values
Element
|
Attribute
|
Value
|
chair
|
type
|
wood
|
chair
|
type
|
plastic
|
para
|
id
|
app001
|
para
|
id
|
app002
|
graphic
|
filename
|
train.tif
|
graphic
|
filename
|
boat.tif
|
In the table above, the element chair has an attribute type. You can enter an attribute value to differentiate between a wooden chair (attribute value of wood) or a plastic chair (attribute value of plastic).
If your document has, for example, a paragraph element para with an id attribute, you can identify the specific paragraph. You enter a value (ID name) in the id attribute of the para tag for that specific paragraph. Another example is a graphic tag with a filename attribute to indicate the graphic file to be used in the document. Changing the filename attribute value to another graphic filename, inserts a different graphic in the document.
The document type definition (DTD) defines the attributes for the elements. The purpose of adding attributes to elements is to assign special properties that help the process of automating certain aspects of document production, such as document assembly.
Attributes can be of various types, which indicate the kinds of attribute values permitted. A few attribute types have special properties. When an attribute of type ID is declared in the DTD, then the value of that attribute in the document instance must be unique to distinguish it from other elements of the same type in the document. Another attribute is then defined as type IDREF (reference identifier) and is used in cross-referencing. When referring to a specific element tag, the IDREF attribute value would be the same as that element tag ID attribute value. By convention, attributes of type ID are frequently named id.
The DTD determines whether the attribute values are required or optional. For example, an ID attribute value could be optional (if not needed) while a graphic filename value required (to identify the graphic file used).
Attribute values are displayed on the start tags themselves (by default), but may be turned off using a display option.