Grammatical Conventions
We use a number of typographic and punctuation conventions to make our grammar easy to understand.
Typographic and Naming Conventions
For our grammar, we denote the terminals with a monospaced typeface. The nonterminals appear in italicized text.
We also use a simple naming convention for the majority of our
nonterminals: if a nonterminal defines the syntax of a specific tag,
its name is the tag name followed by _tag
. If a nonterminal defines the various
language elements that may be nested within a certain tag, its name is
the tag name followed by _content
.
For example, if you are wondering exactly which elements are
allowed within an <a>
tag,
you can look for the a_content
rule
within the grammar. Similarly, to determine the correct syntax of a
definition list created with the <dl>
tag, look for the dl_tag
rule.
Punctuation Conventions
Each rule in the grammar starts with the rule’s name, followed
by the replacement symbol (::=
) and
the rule’s value. We’ve intentionally kept the grammar simple, but we
do use three punctuation elements to denote alternation, repetition,
and optional elements in the grammar.
Alternation
Alternation indicates a rule may actually have several
different values, of which you must choose exactly one. Pipes
(|
) separate the alternatives for
the rule.
For example, the heading
rule is equivalent to any one of six HTML heading tags, so it
appears in the table as:
heading
::=h1_tag
|h2_tag
|h3_tag
|h4_tag
|h5_tag
|h6_tag
The heading ...
Get HTML & XHTML: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.