Quackit Logo
HTML
CSS
Scripting
Database
Hosting
Design
XML

Print Version

DTD Attribute Default Values

In the example in the previous lesson, we defined an attribute using a default value of "No". In this lesson, we look at the various options for defining default values for your attributes.

Default Values

The attribute TYPE field can be set to one of the following values:

ValueDescription
valueA simple text value, enclosed in quotes.
#IMPLIEDSpecifies that there is no default value for this attribute, and that the attribute is optional.
#REQUIREDThere is no default value for this attribute, but a a value must be assigned.
#FIXED valueThe #FIXED part specifies that the value must be the value provided. The value part represents the actual value.

Examples of these default values follow.

value

You can provide an actual value to be the default value by placing it in quotes.

Syntax:

<!ATTLIST element_name
attribute_name CDATA "default_value">

Example:

<!ATTLIST tutorial
published CDATA "No">

#REQUIRED

The #REQUIRED keyword specifies that you won't be providing a default value, but that you require that anyone using this DTD does provide one.

Syntax:

<!ATTLIST element_name
attribute_name CDATA #REQUIRED>

Example:

<!ATTLIST tutorial
published CDATA #REQUIRED>

#IMPLIED

The #IMPLIED keyword specifies that you won't be providing a default value, and that the attribute is optional for users of this DTD.

Syntax:

<!ATTLIST element_name
attribute_name CDATA #IMPLIED>

Example:

<!ATTLIST tutorial
rating CDATA #IMPLIED>

#FIXED

The #FIXED keyword specifies that you will provide value, and that's the only value that can be used by users of this DTD.

Syntax:

<!ATTLIST element_name
attribute_name CDATA #FIXED "value">

Example:

<!ATTLIST tutorial
language CDATA #FIXED "EN">

Enjoy this website?

  • Share
  • Add this page to your Favorites
  • Link to this page (copy/paste into your own website or blog):
  • Link to Quackit using one of these banner ads.
  • Help support Quackit by making a donation

Oh, and thank you for supporting Quackit!

© Copyright 2000 - 2010 Quackit.com