Which HTML 3.2 constructs are not allowed in HTML 4.0?

Introduction

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.

Deprecated elements

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:

Deprecated attributes

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:

Syntax changes

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.

Incompatibilies of rules for attributes

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

Valid HTML 4.0!