Although HTML 4.0 is mostly an extension of HTML 3.2, there are some incompatibilities, i.e. some constructs which are legal in HTML 3.2 but not in HTML 4.0. This applies especially to the "Strict", or recommended, variant of HTML 4.0, which lacks most of the presentational attributes. But there are even some HTML 3.2 constructs which are not legal according to "Transitional" HTML 4.0 either.
The HTML 4.0 specification contains the appendix Changes between HTML 3.2 and HTML 4.0, but the information there mainly lists the extensions. It mentions the deprecated elements as well, and it refers to the general Index of Attributes for information about deprecated attributes, which are marked with a "D" in that index. It does not discuss the effect of changed content models, i.e. the syntactic rules for nesting element, or incompatibilies of rules for attributes
This document aims at clarifying the situation by describing the incompatibilities between HTML 3.2 and HTML 4.0 more explicitly.
The following elements, which are legal in HTML 3.2, have been deprecated in HTML 4.0. This means that documents using them do not validate under HTML 4.0 Strict DTD, but they validate (if they are otherwise correct) under HTML 4.0 Transitional DTD.
element | recommended replacement |
---|---|
APPLET |
OBJECT |
BASEFONT |
style sheets |
CENTER |
style sheets |
DIR |
UL
(and
style sheets) |
FONT |
style sheets |
ISINDEX |
FORM
(containing an
INPUT
TYPE="TEXT" element
and an
INPUT TYPE="SUBMIT" element)
|
MENU |
UL
(and
style sheets) |
STRIKE |
DEL (see note below) |
U |
style sheets |
Notes:
S
element as being one of the HTML 3.2 elements deprecated in HTML 4.0,
but it actually does not belong to HTML.
(This is mentioned in
the Errata.)
LISTING
, PLAINTEXT
, and
XMP
are
obsolete,
as they were in HTML 3.2
(and already in HTML 2.0).STRIKE
should be replaced, but the obvious choice
in the normal case (where STRIKE
has been used
to mark deletions) is DEL
. If STRIKE
has been used for some decorative purpose only, it should be
replaced by the use of style sheets.
The following presentational attributes (for elements which themselves are not deprecated) are deprecated, in favor of style sheets. Documents using them do not validate under HTML 4.0 Strict DTD, but they validate (if they are otherwise correct) under HTML 4.0 Transitional DTD.
Element | Deprecated attribute(s) |
---|---|
BODY |
ALINK , BACKGROUND ,
BGCOLOR , LINK , TEXT ,
VLINK |
BR | CLEAR |
CAPTION | ALIGN |
DIV | ALIGN |
DL | COMPACT |
H1 thru H6 |
ALIGN |
HR | ALIGN ,
NOSHADE , SIZE , WIDTH |
HTML | VERSION |
IMG | ALIGN ,
BORDER , HSPACE , VSPACE |
INPUT | ALIGN |
LI | TYPE ,
VALUE |
OL | COMPACT ,
START , TYPE |
P | ALIGN |
PRE | WIDTH |
TABLE | ALIGN |
TD and TH |
HEIGHT , NOWRAP ,
WIDTH |
UL | COMPACT ,
TYPE |
Notes:
WIDTH
and HEIGHT
in IMG
elements
is
unclear. The specification says, right under the section
heading
as follows:
andAll IMG and OBJECT attributes that concern visual alignment and presentation have been deprecated in favor of style sheets.
WIDTH
and HEIGHT
are described in
a subsection under that.
But on the other hand, these attributes are not flagged as
deprecated in the
Index of Attributes,
and they appear in the
HTML 4.0 Strict DTD.
HREF
attribute of BASE
is not deprecated.
ALIGN
attribute for a TD
element.The following table tries to summarize how some HTML 3.2 constructs have become illegal in HTML 4.0, at least in HTML 4.0 Strict (in addition to some elements and attributes being deprecated, as mentioned above):
element | change | scope of change |
---|---|---|
ADDRESS | may not contain P elements
| Strict |
BLOCKQUOTE |
within these elements,
direct text-level markup
without intervening block-level markup
not allowed; in practice, text must be enclosed into P elements
(or equivalent)
| Strict |
BODY |
||
FORM |
||
IMG | ALT attribute is now
obligatory | both Strict and Transitional |
MAP | empty content is not allowed | both Strict and Transitional, but theoretical change
only |
TR | empty content is not allowed (at least one cell element must appear) | both Strict and Transitional, but probably theoretical change
only |
In an AREA
element, the ALT
attribute
was obligatory already in HTML 3.2 (although this fact is not
widely known).
The change to the content model of the BODY
element
applies to the document body in general; it does not depend on
whether the tags <BODY>
and </BODY>
are explicitly written or implied. Thus, for example, the following
document is not valid under HTML 4.0 strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<TITLE>Demo</TITLE>
Demonstration only
since the text Demonstration only
is plain text within
a BODY
element (the start and end tags of which are implied).
The minimal fix to this is to precede that text with
<P>
.
Similarly, in HTML 4.0 Strict a heading element, for example, must not
be followed by plain text; even the first paragraph after the heading
must be marked up with P
or equivalent.
In HTML 3.2, the STYLE
and SCRIPT
element
are defined as having no attributes.
On the other hand, in HTML 4.0 (both Strict and Transitional)
they are required to have a TYPE
attribute (specifying a content type, i.e. media type).
Disclaimer: I may have missed several changes. Please inform me if you know about them.
Originally written: January 7th, 1998. Last update: January 12th, 1998.
Jukka Korpela