Home /Modules/html-spec/sgmltut.html

sgmltut.html

html-spec/specifications/prose/html-4.01/intro/sgmltut.html · 872 line(s) · html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>On SGML and HTML</title>
<link rel="previous" href="intro.html">
<link rel="next" href="../conform.html">
<link rel="contents" href="../cover.html#toc">
<link rel="stylesheet" type="text/css" href= 
"http://www.w3.org/StyleSheets/TR/W3C-REC">
<link rel="STYLESHEET" href="../style/default.css" type="text/css">
</head>
<body>
<div class="navbar" align="center">&nbsp;<a href="intro.html">previous</a>
&nbsp; <a href="../conform.html">next</a> &nbsp; <a href=
"../cover.html#minitoc">contents</a> &nbsp; <a href="../index/elements.html">
elements</a> &nbsp; <a href="../index/attributes.html">attributes</a> &nbsp; <a
href="../index/list.html">index</a> 

<hr></div>

<h1 align="center"><a name="h-3">3</a> On SGML and HTML</h1>

<div class="subtoc">
<p><strong>Contents</strong></p>

<ol>
<li><a class="tocxref" href="#h-3.1">Introduction to SGML</a></li>

<li><a class="tocxref" href="#h-3.2">SGML constructs used in HTML</a> 

<ol>
<li><a class="tocxref" href="#h-3.2.1">Elements</a></li>

<li><a class="tocxref" href="#h-3.2.2">Attributes</a></li>

<li><a class="tocxref" href="#h-3.2.3">Character references</a></li>

<li><a class="tocxref" href="#h-3.2.4">Comments</a></li>
</ol>
</li>

<li><a class="tocxref" href="#h-3.3">How to read the HTML DTD</a> 

<ol>
<li><a class="tocxref" href="#h-3.3.1">DTD Comments</a></li>

<li><a class="tocxref" href="#h-3.3.2">Parameter entity definitions</a></li>

<li><a class="tocxref" href="#h-3.3.3">Element declarations</a> 

<ul>
<li><a class="tocxref" href="#h-3.3.3.1">Content model definitions</a></li>
</ul>
</li>

<li><a class="tocxref" href="#h-3.3.4">Attribute declarations</a> 

<ul>
<li><a class="tocxref" href="#h-3.3.4.1">DTD entities in attribute
definitions</a></li>

<li><a class="tocxref" href="#h-3.3.4.2"><span class="index-def" title="boolean 
attribute|attribute::boolean">Boolean attributes</span></a></li>
</ul>
</li>
</ol>
</li>
</ol>
</div>

<p>This section of the document introduces <span class="index-inst" title= 
"SGML::introduction to"><a name="idx-SGML-4">SGML</a></span> and discusses its
relationship to HTML. A complete discussion of SGML is left to the standard
(see <a rel="biblioentry" href="../references.html#ref-ISO8879" class=
"normref">[ISO8879]</a>).</p>

<h2><a name="h-3.1">3.1</a> Introduction to SGML</h2>

<p>SGML is a system for defining <span class="index-def" title="markup
language"><a name="didx-markup_language">markup languages</a></span>. Authors
<span class="index-def" title="markup"><a name="didx-markup"><dfn>mark
up</dfn></a></span> their documents by representing structural, presentational,
and semantic information alongside content. HTML is one example of a markup
language. Here is an example of an HTML document:</p>

<div class="example">
<pre>
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
     "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;HTML&gt;
   &lt;HEAD&gt;
      &lt;TITLE&gt;My first HTML document&lt;/TITLE&gt;
   &lt;/HEAD&gt;
   &lt;BODY&gt;
      &lt;P&gt;Hello world!
   &lt;/BODY&gt;
&lt;/HTML&gt;
</pre>

<p>An HTML document is divided into a head section (here, between &lt;HEAD&gt;
and &lt;/HEAD&gt;) and a body (here, between &lt;BODY&gt; and &lt;/BODY&gt;).
The title of the document appears in the head (along with other information
about the document), and the content of the document appears in the body. The
body in this example contains just one paragraph, marked up with &lt;P&gt;.</p>
</div>

<p>Each markup language defined in SGML is called an <span class="index-def"
title="SGML::application"><a name="didx-SGML"><dfn>SGML
application</dfn>.</a></span> An SGML application is generally characterized
by:</p>

<ol>
<li><a href="../sgml/sgmldecl.html">An SGML declaration</a>. The <span class= 
"index-def" title="SGML::declaration"><a name="didx-SGML-1"><dfn>SGML
declaration</dfn></a></span> specifies which characters and delimiters may
appear in the application.</li>

<li><a href="../sgml/dtd.html">A <dfn>document type definition</dfn> (DTD)</a>.
The <span class="index-def" title="document type definition|SGML::document type 
definition (DTD)"><a name="didx-document_type_definition">DTD</a></span>
defines the syntax of markup constructs. The DTD may include additional
definitions such as <a href="#character-entities">character entity
references</a>.</li>

<li>A specification that describes the semantics to be ascribed to the markup.
This specification also imposes syntax restrictions that cannot be expressed
within the DTD.</li>

<li>Document instances containing data (content) and markup. Each instance
contains a reference to the DTD to be used to interpret it.</li>
</ol>

<p>This specification includes an <a href="../sgml/sgmldecl.html">SGML
declaration</a>, three document type definitions (see the section on <a href= 
"../struct/global.html">HTML version information</a> for a description of the
three), and a list of <a href="#character-entities">character
references</a>.</p>

<h2><a name="h-3.2">3.2</a> SGML constructs used in HTML</h2>

<p>The following sections introduce SGML constructs that are used in HTML.</p>

<p>The appendix lists some <a href="../appendix/notes.html#sgmlfeatures">SGML
features</a> that are not widely supported by HTML tools and user agents and
should be avoided.</p>

<h3><a name="h-3.2.1">3.2.1</a> Elements</h3>

<p>An SGML <a href="../sgml/dtd.html">document type definition</a> declares
<span class="index-def" title="element::types"><a name="didx-element"><dfn>
element types</dfn></a></span> that represent structures or desired behavior.
HTML includes element types that represent paragraphs, hypertext links, lists,
tables, images, etc.</p>

<p>Each <span class="index-def" title="SGML::element type 
declaration|element::type declaration"><a name="didx-SGML-3"><dfn>element type
declaration</dfn></a></span> generally describes three parts: a start tag,
content, and an end tag.</p>

<p>The element's name appears in the <span class="index-def" title= 
"element::start tag|start tag"><a name="didx-element-2"><dfn>start
tag</dfn></a></span> (written <samp>&lt;element-name&gt;</samp>) and the <span
class="index-def" title="element::end tag|end tag"><a name="didx-element-3">
<dfn>end tag</dfn></a></span> (written <samp>&lt;/element-name&gt;</samp>);
note the slash before the element name in the end tag. For example, the start
and end tags of the <a href="../struct/lists.html#edef-UL" class="noxref"><samp
class="einst">UL</samp></a> element type delimit the items in a list:</p>

<div class="example">
<pre>
&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;<em>...list item 1...</em>
&lt;LI&gt;&lt;P&gt;<em>...list item 2...</em>
&lt;/UL&gt;
</pre>
</div>

<p>Some HTML element types allow authors to <span class="index-inst" title= 
"element::omitted end tag|end tag::omitted"><a name="idx-element-8">
omit</a></span> end tags (e.g., the <a href="../struct/text.html#edef-P" class= 
"noxref"><samp class="einst">P</samp></a> and <a href= 
"../struct/lists.html#edef-LI" class="noxref"><samp class="einst">LI</samp></a>
element types). A few element types also allow the <span class="index-inst"
title="element::omitted start tag|start tag::omitted"><a name="idx-element-9">
start tags</a></span> to be omitted; for example, <a href= 
"../struct/global.html#edef-HEAD" class="noxref"><samp class="einst">
HEAD</samp></a> and <a href="../struct/global.html#edef-BODY" class="noxref">
<samp class="einst">BODY</samp></a>. The HTML DTD indicates for each element
type whether the start tag and end tag are required.</p>

<p>Some HTML element types have no content. For example, the line break element
<a href="../struct/text.html#edef-BR" class="noxref"><samp class="einst">
BR</samp></a> has no content; its only role is to terminate a line of text.
Such <span class="index-def" title="element::empty"><a name="didx-element-4">
<dfn>empty</dfn></a></span> elements never have end tags. The <a href= 
"../sgml/dtd.html">document type definition</a> and the text of the
specification indicate whether an element type is empty (has no content) or, if
it can have content, what is considered legal content.</p>

<p>Element names are always <span class="index-inst" title="case::of element 
names|element::case-insensitive"><a name="idx-case">
case-insensitive.</a></span></p>

<p>Please consult the SGML standard for information about rules governing
elements (e.g., they must be properly nested, an end tag closes, back to the
matching start tag, all unclosed intervening start tags with omitted end tags
(section 7.5.1), etc.).</p>

<div class="example">
<p>For example, the following paragraph:</p>

<pre>
&lt;P&gt;This is the first paragraph.&lt;/P&gt;
<em>...a block element...</em>
</pre>

<p>may be rewritten without its end tag:</p>

<pre>
&lt;P&gt;This is the first paragraph.
<em>...a block element...</em>
</pre>

<p>since the &lt;P&gt; start tag is closed by the following block element.
Similarly, if a paragraph is enclosed by a block element, as in:</p>

<pre>
&lt;DIV&gt;
&lt;P&gt;This is the paragraph.
&lt;/DIV&gt;
</pre>

<p>the end tag of the enclosing block element (here, &lt;/DIV&gt;) implies the
end tag of the open &lt;P&gt; start tag.</p>
</div>

<div class="note">
<p><em><strong>Elements are not tags.</strong> Some people refer to elements as
tags (e.g., "the P tag"). Remember that the element is one thing, and the tag
(be it start or end tag) is another. For instance, the HEAD element is always
present, even though both start and end HEAD tags may be missing in the
markup.</em></p>
</div>

<p>All the element types declared in this specification are listed in the <a
href="../index/elements.html">element index</a>.</p>

<h3><a name="h-3.2.2">3.2.2</a> <a name="attributes">Attributes</a></h3>

<p>Elements may have associated properties, called <span class="index-def"
title="attribute"><a name="didx-attribute"><dfn>attributes</dfn></a></span>,
which may have values (by default, or set by authors or scripts).
Attribute/value pairs appear before the final "&gt;" of an element's start tag.
Any number of (legal) attribute value pairs, separated by spaces, may appear in
an element's start tag. They may appear in any order.</p>

<div class="example">
<p>In this example, the <a href="../struct/global.html#adef-id" class="noxref">
<samp class="ainst">id</samp></a> attribute is set for an <a href= 
"../struct/global.html#edef-H1" class="noxref"><samp class="einst">
H1</samp></a> element:</p>

<pre>
&lt;H1 id="section1"&gt;
This is an identified heading thanks to the id attribute
&lt;/H1&gt; 
</pre>
</div>

<p>By default, SGML requires that all attribute values be <span class= 
"index-inst" title="attribute::quotation marks around value"><a name= 
"idx-attribute-6">delimited</a></span> using either double quotation marks
(ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote
marks can be included within the attribute value when the value is delimited by
double quote marks, and vice versa. Authors may also use <a href= 
"#character-entities">numeric character references</a> to represent double
quotes (&amp;#34;) and single quotes (&amp;#39;). For double quotes authors can
also use the <a href="#character-entities">character entity reference</a>
&amp;quot;.</p>

<p>In certain cases, authors may specify the value of an attribute without any
quotation marks. The attribute value may only contain letters (a-z and A-Z),
digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46),
underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend
using quotation marks even when it is possible to eliminate them.</p>

<p>Attribute names are always <span class="index-inst" title= 
"attribute::case-insensitive|case::of attribute names"><a name=
"idx-attribute-7">case-insensitive.</a></span></p>

<p>Attribute values are generally <span class="index-inst" title="case::of 
attribute values"><a name="idx-case-2">case-insensitive.</a></span> The
definition of each attribute in the reference manual indicates whether its
value is case-insensitive.</p>

<p>All the attributes defined by this specification are listed in the <a href= 
"../index/attributes.html">attribute index</a>.</p>

<h3><a name="h-3.2.3">3.2.3</a> <a name="character-entities">Character
references</a></h3>

<p><span class="index-inst" title="character reference"><a name= 
"idx-character_reference"><dfn>Character references</dfn></a></span> are
numeric or symbolic names for characters that may be included in an HTML
document. They are useful for referring to rarely used characters, or those
that authoring tools make it difficult or impossible to enter. You will see
character references throughout this document; they begin with a "&amp;" sign
and end with a semi-colon (;). Some common examples include:</p>

<ul>
<li>"&amp;lt;" represents the &lt; sign.</li>

<li>"&amp;gt;" represents the &gt; sign.</li>

<li>"&amp;quot;" represents the " mark.</li>

<li>"&amp;#229;" (in decimal) represents the letter "a" with a small circle
above it.</li>

<li>"&amp;#1048;" (in decimal) represents the Cyrillic capital letter "I".</li>

<li>"&amp;#x6C34;" (in hexadecimal) represents the Chinese character for
water.</li>
</ul>

<p>We discuss <a href="../charset.html#entities">HTML character references</a>
in detail later in the section on the <a href="../charset.html">HTML document
character set</a>. The specification also contains a <a href= 
"../sgml/entities.html">list of character references</a> that may appear in
HTML 4 documents.</p>

<h3><a name="h-3.2.4">3.2.4</a> Comments</h3>

<p><span class="index-inst" title="HTML::comments in|comments::in HTML"><a
name="idx-HTML">HTML comments</a></span> have the following syntax:</p>

<div class="example">
<pre>
&lt;!-- this is a comment --&gt;
&lt;!-- and so is this one,
    which occupies more than one line --&gt;
</pre>
</div>

<p>White space is not permitted between the markup declaration open
delimiter("&lt;!") and the comment open delimiter ("--"), but is permitted
between the comment close delimiter ("--") and the markup declaration close
delimiter ("&gt;"). A common error is to include a string of hyphens ("---")
within a comment. Authors should avoid putting two or more adjacent hyphens
inside comments.</p>

<p>Information that appears between comments has no special meaning (e.g., <a
href="#character-entities">character references</a> are not interpreted as
such).</p>

<p>Note that comments are markup.</p>

<h2><a name="h-3.3">3.3</a> <a name="howtodtd">How to read the HTML
DTD</a></h2>

<p>Each element and attribute declaration in this specification is accompanied
by its <a href="../sgml/dtd.html">document type definition</a> fragment. We
have chosen to include the DTD fragments in the specification rather than seek
a more approachable, but longer and less precise means of describing an
element's properties. The following <span class="index-inst" title="document 
type definition::how to read"><a name="idx-document_type_definition-1">
tutorial</a></span> should allow readers unfamiliar with SGML to read the DTD
and understand the technical details of the HTML specification.</p>

<h3><a name="h-3.3.1">3.3.1</a> DTD Comments</h3>

<p>In DTDs, <span class="index-inst" title="comments::in DTD|document type 
definition::comments in"><a name="idx-comments-1">comments</a></span> may
spread over one or more lines. In the DTD, comments are delimited by a pair of
"--" marks, e.g.</p>

<div class="dtd-example">
<pre>
&lt;!ELEMENT PARAM - O EMPTY       -- named property value --&gt;
</pre>
</div>

Here, the comment "named property value" explains the use of the <a href= 
"../struct/objects.html#edef-PARAM" class="noxref"><samp class="einst">
PARAM</samp></a> element type. Comments in the DTD are informative only. 

<h3><a name="h-3.3.2">3.3.2</a> Parameter entity definitions</h3>

<p>The <a href="../sgml/dtd.html">HTML DTD</a> begins with a series of
parameter entity definitions. A <span class="index-def" title="parameter entity 
definition"><a name="didx-parameter_entity_definition"><dfn>parameter entity
definition</dfn></a></span> defines a kind of macro that may be referenced and
expanded elsewhere in the DTD. These macros may not appear in HTML documents,
only in the DTD. Other types of macros, called <a href="#character-entities">
character references</a>, may be used in the text of an HTML document or within
attribute values.</p>

<p>When the parameter entity is referred to by name in the DTD, it is expanded
into a string.</p>

<p>A parameter entity definition begins with the keyword <tt>&lt;!ENTITY %</tt>
followed by the entity name, the quoted string the entity expands to, and
finally a closing <tt>&gt;</tt>. Instances of parameter entities in a DTD begin
with "%", then the parameter entity name, and terminated by an optional
";".</p>

<div class="dtd-example">
<p>The following example defines the string that the "%fontstyle;" entity will
expand to.</p>

<pre>
&lt;!ENTITY % fontstyle "TT | I | B | BIG | SMALL"&gt;
</pre>
</div>

<p>The string the parameter entity expands to may contain other parameter
entity names. These names are expanded recursively. In the following example,
the "%inline;" parameter entity is defined to include the "%fontstyle;",
"%phrase;", "%special;" and "%formctrl;" parameter entities.</p>

<div class="dtd-example">
<pre>
&lt;!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;"&gt;
</pre>
</div>

<p>You will encounter two DTD entities frequently in the <a href= 
"../sgml/dtd.html">HTML DTD</a>: <span class="index-inst" title="parameter 
entity::%block;|%block;"><a name="idx-parameter_entity-1">"%block;"</a></span>
<span class="index-inst" title="parameter entity::%inline;|%inline;"><a name= 
"idx-parameter_entity-2">"%inline;".</a></span> They are used when the content
model includes <a href="../struct/global.html#block-inline">block-level and
inline elements</a>, respectively (defined in the section on the <a href= 
"../struct/global.html">global structure of an HTML document</a>).</p>

<h3><a name="h-3.3.3">3.3.3</a> <a name="element-defs">Element
declarations</a></h3>

<p>The bulk of the HTML DTD consists of the declarations of <span class= 
"index-def" title="element::type declaration"><a name="didx-element-5"><dfn>
element types</dfn></a></span> and their attributes. The &lt;!ELEMENT keyword
begins a declaration and the &gt; character ends it. Between these are
specified:</p>

<ol>
<li>The element's name.</li>

<li>Whether the element's tags are <span class="index-inst" title="end 
tag::declared as optional"><a name="idx-end_tag-2">optional</a></span>. Two
hyphens that appear after the element name mean that the start and end tags are
mandatory. One hyphen followed by the letter "O" indicates that the end tag can
be omitted. A pair of letter "O"s indicate that both the start and end tags can
be omitted.</li>

<li>The element's content, if any. The allowed content for an element is called
its <span class="index-def" title="content model|element::content model of"><a
name="didx-content_model"><dfn>content model.</dfn></a></span> Element types
that are designed to have no content are called <span class="index-def" title= 
"empty element|element::empty"><a name="didx-empty_element"><dfn>empty
elements</dfn></a></span>. The content model for such element types is declared
using the keyword "EMPTY".</li>
</ol>

<div class="dtd-example">
<p>In this example:</p>

<pre>
    &lt;!ELEMENT UL - - (LI)+&gt;
</pre>

<ul>
<li>The element type being declared is <strong>UL</strong>.</li>

<li>The two hyphens indicate that both the start tag &lt;UL&gt; and the end tag
&lt;/UL&gt; for this element type are required.</li>

<li>The content model for this element type is declared to be "at least one LI
element". Below, we explain how to specify content models.</li>
</ul>
</div>

<div class="dtd-example">
<p>This example illustrates the declaration of an empty element type:</p>

<pre>
    &lt;!ELEMENT IMG - O EMPTY&gt;
</pre>

<ul>
<li>The element type being declared is <strong>IMG</strong>.</li>

<li>The hyphen and the following "O" indicate that the end tag can be omitted,
but together with the content model "EMPTY", this is strengthened to the rule
that the end tag <b>must</b> be omitted.</li>

<li>The "EMPTY" keyword means that instances of this type must not have
content.</li>
</ul>
</div>

<h4>Content model definitions<a name="h-3.3.3.1">&nbsp;</a></h4>

<p>The content model describes what may be contained by an instance of an
element type. <span class="index-inst" title="content model::syntax of in DTD">
<a name="idx-content_model-1">Content model</a></span> definitions may
include:</p>

<ul>
<li>The names of allowed or forbidden element types (e.g., the <a href= 
"../struct/lists.html#edef-UL" class="noxref"><samp class="einst">UL</samp></a>
element contains instances of the <a href="../struct/lists.html#edef-LI" class= 
"noxref"><samp class="einst">LI</samp></a> element type, and the <a href= 
"../struct/text.html#edef-P" class="noxref"><samp class="einst">P</samp></a>
element type may not contain other <a href="../struct/text.html#edef-P" class= 
"noxref"><samp class="einst">P</samp></a> elements).</li>

<li>DTD entities (e.g., the <a href="../interact/forms.html#edef-LABEL" class= 
"noxref"><samp class="einst">LABEL</samp></a> element contains instances of the
"%inline;" parameter entity).</li>

<li>Document text (indicated by the SGML construct "#PCDATA"). Text may contain
<a href="../charset.html#entities">character references</a>. Recall that these
begin with &amp; and end with a semicolon (e.g., "Herg&amp;eacute;'s adventures
of Tintin" contains the character entity reference for the "e acute"
character).</li>
</ul>

<p>The content model of an element is specified with the following syntax.
Please note that the list below is a simplification of the full SGML syntax
rules and does not address, e.g., precedences.</p>

<dl>
<dt><strong>( ... )</strong></dt>

<dd>Delimits a group.</dd>

<dt><strong>A</strong></dt>

<dd>A must occur, one time only.</dd>

<dt><strong>A+</strong></dt>

<dd>A must occur one or more times.</dd>

<dt><strong>A?</strong></dt>

<dd>A must occur zero or one time.</dd>

<dt><strong>A*</strong></dt>

<dd>A may occur zero or more times.</dd>

<dt><strong>+(A)</strong></dt>

<dd>A may occur.</dd>

<dt><strong>-(A)</strong></dt>

<dd>A must not occur.</dd>

<dt><strong>A | B</strong></dt>

<dd>Either A or B must occur, but not both.</dd>

<dt><strong>A , B</strong></dt>

<dd>Both A and B must occur, in that order.</dd>

<dt><strong>A &amp; B</strong></dt>

<dd>Both A and B must occur, in any order.</dd>
</dl>

<div class="dtd-example">
<p>Here are some examples from the HTML DTD:</p>

<pre>
   &lt;!ELEMENT UL - - (LI)+&gt;
</pre>

<p>The <a href="../struct/lists.html#edef-UL" class="noxref"><samp class=
"einst">UL</samp></a> element must contain one or more <a href= 
"../struct/lists.html#edef-LI" class="noxref"><samp class="einst">LI</samp></a>
elements.</p>

<pre>
   &lt;!ELEMENT DL    - - (DT|DD)+&gt;
</pre>

<p>The <a href="../struct/lists.html#edef-DL" class="noxref"><samp class=
"einst">DL</samp></a> element must contain one or more <a href= 
"../struct/lists.html#edef-DT" class="noxref"><samp class="einst">DT</samp></a>
or <a href="../struct/lists.html#edef-DD" class="noxref"><samp class="einst">
DD</samp></a> elements in any order.</p>

<pre>
   &lt;!ELEMENT OPTION - O (#PCDATA)&gt;
</pre>

<p>The <a href="../interact/forms.html#edef-OPTION" class="noxref"><samp class= 
"einst">OPTION</samp></a> element may only contain text and entities, such as
&amp;amp; -- this is indicated by the SGML data type #PCDATA.</p>
</div>

<p>A few HTML element types use an additional SGML feature to exclude elements
from their content model. <span class="index-inst" title="content 
model::excluded elements in"><a name="idx-content_model-2">Excluded
elements</a></span> are preceded by a hyphen. Explicit exclusions override
permitted elements.</p>

<div class="dtd-example">
<p>In this example, the <tt>-(A)</tt> signifies that the element <a href= 
"../struct/links.html#edef-A" class="noxref"><samp class="einst">A</samp></a>
cannot appear in another <a href="../struct/links.html#edef-A" class="noxref">
<samp class="einst">A</samp></a> element (i.e., anchors may not be nested).</p>

<pre>
   &lt;!ELEMENT A - - (%inline;)* -(A)&gt;
</pre>

<p>Note that the <a href="../struct/links.html#edef-A" class="noxref"><samp
class="einst">A</samp></a> element type is part of the DTD parameter entity
"%inline;", but is excluded explicitly because of <tt>-(A)</tt>.</p>

<p>Similarly, the following element type declaration for <a href= 
"../interact/forms.html#edef-FORM" class="noxref"><samp class="einst">
FORM</samp></a> prohibits nested forms:</p>

<pre>
   &lt;!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM)&gt;
</pre>
</div>

<h3><a name="h-3.3.4">3.3.4</a> <a name="attrib-defs">Attribute
declarations</a></h3>

<p>The &lt;!ATTLIST keyword begins the <span class="index-inst" title= 
"attribute::declaration of in DTD"><a name="idx-attribute-8">declaration of
attributes</a></span> that an element may take. It is followed by the name of
the element in question, a list of attribute definitions, and a closing &gt;.
Each attribute definition is a triplet that defines:</p>

<ul>
<li>The name of an attribute.</li>

<li>The type of the attribute's value or an explicit set of possible values.
Values defined explicitly by the DTD are <span class="index-inst" title= 
"attribute::case of values|case::of attribute values"><a name=
"idx-attribute-9">case-insensitive.</a></span> Please consult the section on <a
href="../types.html">basic HTML data types</a> for more information about
attribute value types.</li>

<li>Whether the default value of the attribute is <span class="index-def"
title="#IMPLIED attribute value|attribute::#IMPLIED value of"><a name= 
"didx-IMPLIED_attribute_value">implicit</a></span> (keyword "#IMPLIED"), in
which case the default value must be supplied by the user agent (in some cases
via inheritance from parent elements); always <span class="index-def" title= 
"#REQUIRED attribute value|attribute::#REQUIRED value of"><a name= 
"didx-REQUIRED_attribute_value">required</a></span> (keyword "#REQUIRED"); or
<span class="index-def" title="#FIXED attribute value|attribute::#FIXED value
of"><a name="didx-FIXED_attribute_value">fixed</a></span> to the given value
(keyword "#FIXED"). Some attribute definitions explicitly specify a default
value for the attribute.</li>
</ul>

<div class="dtd-example">
<p>In this example, the <a href="../struct/objects.html#adef-name-MAP" class= 
"noxref"><samp class="ainst-MAP">name</samp></a> attribute is defined for the
<a href="../struct/objects.html#edef-MAP" class="noxref"><samp class="einst">
MAP</samp></a> element. The attribute is optional for this element.</p>

<pre>
&lt;!ATTLIST MAP
  name        CDATA     #IMPLIED
  &gt;
</pre>

<p>The type of values permitted for the attribute is given as CDATA, an SGML
data type. <span class="index-inst" title="CDATA"><a name="idx-CDATA">
CDATA</a></span> is text that may contain <a href="../charset.html#entities">
character references</a>.</p>
</div>

<p>For more information about "CDATA", "NAME", "ID", and other data types,
please consult the section on <a href="../types.html">HTML data types</a>.</p>

<div class="dtd-example">
<p>The following examples illustrate several attribute definitions:</p>

<pre>
rowspan     NUMBER     1         -- number of rows spanned by cell --
http-equiv  NAME       #IMPLIED  -- HTTP response header name  --
id          ID         #IMPLIED  -- document-wide unique id -- 
valign      (top|middle|bottom|baseline) #IMPLIED
</pre>

<p>The <tt>rowspan</tt> attribute requires values of type NUMBER. The default
value is given explicitly as "1". The optional <tt>http-equiv</tt> attribute
requires values of type NAME. The optional <tt>id</tt> attribute requires
values of type ID. The optional <tt>valign</tt> attribute is constrained to
take values from the set {top, middle, bottom, baseline}.</p>
</div>

<h4>DTD entities in attribute definitions<a name="h-3.3.4.1">&nbsp;</a></h4>

<p>Attribute definitions may also contain parameter entity references.</p>

<div class="dtd-example">
<p>In this example, we see that the attribute definition list for the <a href= 
"../struct/links.html#edef-LINK" class="noxref"><samp class="einst">
LINK</samp></a> element begins with the "%attrs;" parameter entity.</p>

<div class="dtd-fragment">
<pre class="dtd-fragment">
&lt;!ELEMENT <a href="../struct/links.html#edef-LINK" class="noxref"><samp
class=
"einst">LINK</samp></a> - O EMPTY               -- a media-independent link --&gt;
&lt;!ATTLIST LINK
  <a href=
"../sgml/dtd.html#attrs">%attrs;</a>                              -- <a href= 
"../sgml/dtd.html#coreattrs">%coreattrs</a>, <a href=
"../sgml/dtd.html#i18n">%i18n</a>, <a href=
"../sgml/dtd.html#events">%events</a> --
  <a href="../struct/links.html#adef-charset" class="noxref"><samp class= 
"ainst-LINK">charset</samp></a>     <a href=
"../sgml/dtd.html#Charset">%Charset;</a>      #IMPLIED  -- char encoding of linked resource --
  <a href="../struct/links.html#adef-href" class="noxref"><samp class= 
"ainst-LINK">href</samp></a>        <a href=
"../sgml/dtd.html#URI">%URI;</a>          #IMPLIED  -- URI for linked resource --
  <a href="../struct/links.html#adef-hreflang" class="noxref"><samp class= 
"ainst-LINK">hreflang</samp></a>    <a href=
"../sgml/dtd.html#LanguageCode">%LanguageCode;</a> #IMPLIED  -- language code --
  <a href="../struct/links.html#adef-type-A" class="noxref"><samp class=
"ainst-A">type</samp></a>        <a href=
"../sgml/dtd.html#ContentType">%ContentType;</a>  #IMPLIED  -- advisory content type --
  <a href="../struct/links.html#adef-rel" class="noxref"><samp class=
"ainst-LINK">rel</samp></a>         <a href=
"../sgml/dtd.html#LinkTypes">%LinkTypes;</a>    #IMPLIED  -- forward link types --
  <a href="../struct/links.html#adef-rev" class="noxref"><samp class=
"ainst-LINK">rev</samp></a>         <a href=
"../sgml/dtd.html#LinkTypes">%LinkTypes;</a>    #IMPLIED  -- reverse link types --
  <a href="../present/styles.html#adef-media" class="noxref"><samp class= 
"ainst-LINK">media</samp></a>       <a href=
"../sgml/dtd.html#MediaDesc">%MediaDesc;</a>    #IMPLIED  -- for rendering on these media --
  &gt;
</pre>
</div>

<p><em>Start tag: <strong>required</strong>, End tag: <strong>
forbidden</strong></em></p>

<p>The "%attrs;" parameter entity is defined as follows:</p>

<div class="dtd-fragment">
<pre class="dtd-fragment">
&lt;!ENTITY % attrs "<a href="../sgml/dtd.html#coreattrs">%coreattrs;</a> <a
href="../sgml/dtd.html#i18n">%i18n;</a> <a href=
"../sgml/dtd.html#events">%events;</a>"&gt;
</pre>
</div>

<p>The "%coreattrs;" parameter entity in the "%attrs;" definition expands as
follows:</p>

<div class="dtd-fragment">
<pre class="dtd-fragment">
&lt;!ENTITY % coreattrs
 "<a href="../struct/global.html#adef-id" class="noxref"><samp class=
"ainst">id</samp></a>          <a href=
"../types.html#type-id">ID</a>             #IMPLIED  -- document-wide unique id --
  <a href="../struct/global.html#adef-class" class="noxref"><samp class=
"ainst">class</samp></a>       <a href=
"../types.html#type-cdata">CDATA</a>          #IMPLIED  -- space-separated list of classes --
  <a href="../present/styles.html#adef-style" class="noxref"><samp class=
"ainst">style</samp></a>       <a href=
"../sgml/dtd.html#StyleSheet">%StyleSheet;</a>   #IMPLIED  -- associated style info --
  <a href="../struct/global.html#adef-title" class="noxref"><samp class=
"ainst">title</samp></a>       <a href=
"../sgml/dtd.html#Text">%Text;</a>         #IMPLIED  -- advisory title --"
  &gt;
</pre>
</div>
</div>

<p>The <span class="index-def" title="parameter entity::%attrs;|%attrs;"><a
name="didx-parameter_entity">"%attrs;"</a></span> parameter entity has been
defined for convenience since these attributes are defined for most HTML
element types.</p>

<div class="dtd-example">
<p>Similarly, the DTD defines the "%URI;" parameter entity as expanding into
the string "CDATA".</p>

<div class="dtd-fragment">
<pre class="dtd-fragment">
&lt;!ENTITY % URI "<a href="../types.html#type-cdata">CDATA</a>"
    -- a Uniform Resource Identifier,
       see <a rel="biblioentry" href="../references.html#ref-URI">[URI]</a>
    --&gt;
</pre>
</div>
</div>

<p>As this example illustrates, the parameter entity "%URI;" provides readers
of the DTD with more information as to the type of data expected for an
attribute. Similar entities have been defined for "%Color;", "%Charset;",
"%Length;", "%Pixels;", etc.</p>

<h4><span class="index-def" title="boolean attribute|attribute::boolean"><a
name="didx-boolean_attribute"><dfn>Boolean attributes</dfn></a></span><a name= 
"h-3.3.4.2">&nbsp;</a></h4>

<p>Some attributes play the role of boolean variables (e.g., the <a href= 
"../interact/forms.html#adef-selected" class="noxref"><samp class=
"ainst-OPTION">selected</samp></a> attribute for the <a href= 
"../interact/forms.html#edef-OPTION" class="noxref"><samp class="einst">
OPTION</samp></a> element). Their appearance in the start tag of an element
implies that the value of the attribute is "true". Their absence implies a
value of "false".</p>

<p>Boolean attributes may legally take a single value: the name of the
attribute itself (e.g., <tt>selected="selected"</tt>).</p>

<div class="dtd-example">
<p>This example defines the <a href="../interact/forms.html#adef-selected"
class="noxref"><samp class="ainst-OPTION">selected</samp></a> attribute to be a
boolean attribute.</p>

<pre>
selected     (selected)  #IMPLIED  -- option is pre-selected --
</pre>

<p>The attribute is set to "true" by appearing in the element's start tag:</p>

<pre>
&lt;OPTION selected="selected"&gt;
<em>...contents...</em>
&lt;/OPTION&gt;
</pre>
</div>

<p>In HTML, boolean attributes may appear in <span class="index-def" title= 
"boolean attribute::minimized|attribute::minimized boolean"><a name= 
"didx-boolean_attribute-1"><dfn>minimized form</dfn></a></span> -- the
attribute's <strong>value</strong> appears alone in the element's start tag.
Thus, <a href="../interact/forms.html#adef-selected" class="noxref"><samp
class="ainst-OPTION">selected</samp></a> may be set by writing:</p>

<pre>
&lt;OPTION selected&gt;
</pre>

<p>instead of:</p>

<pre>
&lt;OPTION selected="selected"&gt;
</pre>

<p>Authors should be aware that many user agents <strong>only</strong>
recognize the minimized form of boolean attributes and not the full form.</p>

<div class="navbar" align="center">
<hr><a href="intro.html">previous</a> &nbsp; <a href="../conform.html">next</a>
&nbsp; <a href="../cover.html#minitoc">contents</a> &nbsp; <a href= 
"../index/elements.html">elements</a> &nbsp; <a href=
"../index/attributes.html">attributes</a> &nbsp; <a href="../index/list.html">
index</a></div>
</body>
</html>