Re: An ignorant SGML question

Joe English (
Tue, 10 Jan 1995 02:04:49 +0100 (Michael Johnson) wrote:

Not an ignorant question at all --

> what is the effect of specifying 'O' instead
> of '-' immediately following an element name? The BODY and HEAD elements in
> the HTML3 DTD are defined this way:
> <!ELEMENT BODY O O %body.content>
> <!ELEMENT HEAD O O (%head.content)>
> I've been able to interpret other DTD constructs by context and knowledge of
> regular expressions, but this one eludes me. If I had to guess, I'd guess tha
> t
> it means you can omit the end tag,

Almost: the first '-' or 'O' specifies whether the start-tag
may be omitted, and the second specifies whether the end-tag may be.
'-' means the tag must be present, 'O' means it is omissible
under some circumstances.

In the HTML DTD, start-tag omission is usually used for
container elements (like HEAD and BODY) that were not
in the original specification and that many existing
documents don't include. End-tag omission is usually
used for elements that used to be separators
and were later changed to containers (like LI, DT, and DD),
and for EMPTY elements (like IMG, INPUT, HR, and BR) which
cannot have end-tags anyway.

For backwards- and forwards- compatibility, one hopes that
no new EMPTY elements will ever be introduced.

> but that the tag is not implicitly closed
> by an element that it cannot contain.

Not exactly; the *only* way an element may be closed
is by an explicit end-tag or by an element that it cannot contain.
The latter case is only legal if end-tag omission
('- O' or 'O O') is specified in the <!ELEMENT> declaration.

--Joe English