HTML Allowed Nesting
Allowed nesting of elements in HTML 4 (and XHTML 1.0)
Nesting rules for HTML 4.01 Transitional
HTML
-
HEAD
- TITLE (required)
-
SCRIPT, STYLE
- CDATA
- ISINDEX, BASE, META, LINK (empty)
- OBJECT
-
BODY
- INS, DEL (special rules apply)
- flow
- flow
-
block
-
P, H1, H2, H3, H4, H5, H6
- inline
-
UL, OL
-
LI
- flow
-
LI
-
DIR, MENU
-
LI
- inline exluding block
-
LI
-
DL
-
DT
- inline
-
DD
- flow
-
DT
-
PRE
- inline excluding IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
-
DIV, CENTER, BLOCKQUOTE, IFRAME
- flow
-
NOSCRIPT
- flow
-
NOFRAMES
- flow
-
FORM
- flow excluding an enclosed FORM
- ISINDEX, HR (empty)
-
TABLE
-
CAPTION
- inline
- COLGROUP
- COL (empty)
- COL (empty)
- THEAD, TBODY, TBODY
-
TR
-
TH, TD
- flow
-
TH, TD
-
TR
-
CAPTION
-
ADDRESS
- inline
- P
- inline
-
FIELDSET
- #PCDATA
- flow
- LEGEND
- inline
-
P, H1, H2, H3, H4, H5, H6
- inline
- #PCDATA
-
TT, I, B, U, S, STRIKE, BIG, SMALL, FONT,
EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM,
SUB, SUP, Q, SPAN, BDO
- inline
-
A
- inline excluding an enclosed A element
- OBJECT, APPLET
- PARAM (empty)
- flow
- IMG, BASEFONT, BR (empty)
-
SCRIPT
- CDATA
-
MAP
- AREA (empty)
- block
- INPUT (empty)
-
SELECT
- OPTGROUP
- OPTION
- OPTION
- OPTGROUP
- TEXTAREA
- LABEL
- LABEL excluding enclosed LABEL
- BUTTON
- flow excluding A, INPUT, SELECT, TEXTAREA, LABEL, BUTTON, FORM, ISINDEX, FIELDSET, IFRAME
-
block
- INS, DEL (special rules apply)
Nesting rules for HTML 4.01 Frameset
HTML
- HEAD
- FRAMESET
- FRAMESET (note recursion)
- FRAME (empty)
- NOFRAMES
- BODY
Allowed nesting of elements in HTML 4 Strict (and XHTML 1.0 Strict)
HTML
-
HEAD
- TITLE (required)
-
SCRIPT, STYLE
- CDATA
- BASE, META, LINK (empty)
- OBJECT
-
BODY
- INS, DEL (special rules apply)
- flow
- block
- inline
- flow
-
SCRIPT
- CDATA
-
block
-
P, H1, H2, H3, H4, H5, H6
- inline
- #PCDATA
-
TT, I, B, BIG, SMALL,
EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM,
SUB, SUP, Q, SPAN, BDO
- inline
-
A
- inline excluding an enclosed A element
- OBJECT
- PARAM (empty)
- flow
- IMG, BR (empty)
-
SCRIPT
- CDATA
-
MAP
- AREA (empty)
- block
- INPUT (empty)
-
SELECT
- OPTGROUP
- OPTION
- OPTION
- OPTGROUP
- TEXTAREA
- LABEL
- LABEL excluding enclosed LABEL
- BUTTON
- flow excluding A, INPUT, SELECT, TEXTAREA, LABEL, BUTTON, FORM, FIELDSET
- inline
-
UL, OL
-
LI
- flow
-
LI
-
DL
-
DT
- inline
-
DD
- flow
-
DT
-
PRE
- inline excluding IMG, OBJECT, BIG, SMALL, SUB, SUP
-
DIV
- flow
-
BLOCKQUOTE
- block
- SCRIPT
- CDATA
-
NOSCRIPT
- flow
-
FORM
- block excluding an enclosed FORM
- SCRIPT
- CDATA
- HR (empty)
-
TABLE
-
CAPTION
- inline
- COLGROUP
- COL (empty)
- COL (empty)
- THEAD, TBODY, TBODY
-
TR
-
TH, TD
- flow
-
TH, TD
-
TR
-
CAPTION
-
ADDRESS
- inline
-
FIELDSET
- #PCDATA
- inline
- flow
- LEGEND
- inline
-
P, H1, H2, H3, H4, H5, H6
- INS, DEL (special rules apply)