coding for both HTML 4.01 and xhtml transitional

JQ Johnson jqj at darkwing.uoregon.edu
Sun Sep 8 11:32:02 EDT 2002


I have a project for which I am attempting to generate code that
validates both as HTML 4.01 Transitional and as xhtml 1.0 Transitional.
I'm having difficulty, and wondered if anyone else has suggestions.

Specifically, the issue is the use of "link" elements in the head
section of the document.  In HTML 4.01 I'd code these as, e.g.,
    <link rel="stylesheet" type="text/css" href="style.css">
In xhtml I'd code these minimized as
    <link rel="stylesheet" type="text/css" href="style.css" />

The problem is that the former code does not validate as xhtml, and the
latter does not validate as HTML.  Suggestions?

(note:  "why bother?", you may ask.  The specific application is a
server-side include file that contains standardized header elements.
We'd like our library authors to be able to use the SSI for all
documents on our site and have the resulting URLs validate, whether they
have legacy HTML 4.01 code or spiffy up-to-the-minute xhtml.)

Related question:  apart from formal validation, does *anything* in any
existing browser break if you claim to be HTML 4.01 Transitional but
include the trailing "/" in link tags?

If you don't have an answer to my specific questions, here's another
one:  what is it about the DTD for HTML 4.01 Transitional that allows
trailing slashes on most empty tags, but not on header tags such as LINK
or META?  That is, why is
    <br />
valid HTML 4.01 but
    <link rel="stylesheet" type="text/css" href="style.css" />
not?

JQ Johnson                    	Office: 115F Knight Library
Academic Education Coordinator	e-mail: jqj at darkwing.uoregon.edu
1299 University of Oregon     	1-541-346-1746 (v); -3485 (fax)
Eugene, OR  97403-1299        	http://darkwing.uoregon.edu/~jqj




More information about the Web4lib mailing list