HTML and CSS Reference
In-Depth Information
Appendix A. HTML Grammar
For the most part, browsers do not rigidly enforce the exact syntax of
an HTML or even an XHTML document. This gives authors wide latitude
in creating documents and gives rise to documents that work on most
browsers but actually are incompatible with the HTML and XHTML stand-
ards. Our advice is to stick to the standards, unless your documents are
fly-by-night affairs.
The standards explicitly define the ordering and nesting of tags and doc-
ument elements. This syntax is embedded within the appropriate Docu-
ment Type Definition (DTD) and is not readily understood by those who
are not versed in Standard Generalized Markup Language (SGML; for the
HTML 4.01 DTD, see Appendix D ) or Extensible Markup Language (XML;
for the XHTML 1.0 DTD, see Appendix E ). Accordingly, we provide an al-
ternate definition of the allowable HTML and XHTML syntax, using a fairly
common tool called a grammar .
Grammar, whether it defines English sentences or HTML documents, is
just a set of rules that indicates the order of language elements. These
language elements can be divided into two sets: terminal (the actual
words of the language) and nonterminal (all other grammatical rules). In
HTML and XHTML, the words correspond to the embedded markup tags
and text in a document.
To use the grammar to create a valid document, follow the order of the
rules to see where the tags and text may be placed to create a valid doc-
ument.
 
Search WWH ::




Custom Search