This section describes how elements may be nested in
HTML 3.2.
It does not describe the rules for the ordering or repeatability
of elements. It simply answers questions of the form
may element X appear within element Y?
The same information is presented in the
individual tag descriptions,
in their Allowed context and Contents parts.
Here it is presented in a compact form. This form does not cover all
details but might be more illustrative.
Legend:
- An uppercase word stands for the corresponding element.
- A lowercase word is a term which
describes a collection of HTML elements
- Each entry is followed by an indented list of elements which
may appear within the elements specified by the entry.
If there is no such list, no nested elements are allowed.
However, for block
and text
the allowed contents is as described under that title
- #PCDATA means "parsed character data" (without HTML tags,
but escape sequences
such as ä are allowed)
- body.content
means the elements which are listed under BODY
HTML
-
HEAD
-
TITLE, SCRIPT, STYLE
-
ISINDEX, BASE, META, LINK
-
BODY
-
H1, H2, H3, H4, H5, H6
-
block
-
P
-
UL, OL, DIR, MENU
-
LI
(within DIR or MENU, LI may not contain a block)
-
DL
-
PRE
-
text without IMG, BIG, SMALL, SUB, SUP, FONT
-
DIV, CENTER, BLOCKQUOTE
-
FORM
-
body.content without FORM
-
ISINDEX
-
HR
-
TABLE
-
ADDRESS
-
text
-
#PCDATA
-
TT, I, B, U, STRIKE, BIG, SMALL, SUB, SUP
-
EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE
-
A
-
IMG
-
APPLET
-
FONT
-
BASEFONT, BR
-
SCRIPT
-
MAP
-
INPUT
-
SELECT
-
TEXTAREA
In order to simplify element descriptions, I will use the term
text container
to denote any element which may contain a
text element directly (as opposite to
containing an element which contains a text element).
The following elements are text containers:
A,
ADDRESS,
APPLET,
B,
BIG,
BLOCKQUOTE,
BODY,
CAPTION,
CENTER,
CITE,
CODE,
DD,
DFN,
DIV,
DT,
EM,
FONT,
FORM,
H1,
H2,
H3,
H4,
H5,
H6,
HTML,
I,
KBD,
LI,
P,
PRE (with restrictions),
SAMP,
SMALL,
STRIKE,
STRONG,
SUB,
SUP,
TD,
TH,
TT,
U,
VAR.
The following are not text containers but may contain text elements
indirectly, i.e. contain elements which are text containers:
DIR,
DL,
MENU,
OL,
TABLE,
TR,
UL.
The following may not contain text elements at all:
AREA,
BASE,
BASEFONT,
BR,
HEAD,
HR,
IMG,
INPUT,
ISINDEX,
LINK,
MAP,
META,
OPTION,
PARAM,
SCRIPT,
SELECT,
STYLE,
TEXTAREA,
TITLE,
Similarly I will use the term
block container
to denote any element which may contain a
block element directly (as opposite to
containing an element which contains a block element).
Block containers are:
BLOCKQUOTE,
BODY,
CENTER,
DD,
DIV,
FORM,
HTML,
LI (when within UL or OL),
TD,
TH.
Date of last update:
2010-12-16.