Re: BASE and IMG and [X]HTML

On Mon, 23 Sep 2002 kynn@idyllmtn.com wrote:

> 
> Charlie Reiman asked:
> > We've been having a discussion on the zope mailing list regarding the
> > validator's behavior with <base ... />. In particular, an HTML 4.01
> > transitional document is not allowed to use <base ... />. Instead, it is
> > expected to use <base ...>.

Yes, that's SGML syntax for an empty element.

> > Well, okay. I don't like it but I accept the reasoning. But why does it not
> > complain about <img ... />? Isn't this the same situation?

Yes, but not for the reason you think.

The / closes the tag in both cases, so the ">" is simply a character.
In HTML 4.01 Legacy loose character data is allowed in the <body>
(where <img...> appears) but not in <head ...> (so it is illegal
with <base...>).

This means you will get confusing error messages when you validate,
and is one of many reasons to prefer strict over legacy HTML.

> /
>      Wait, what the heck is this?

SHORTTAG.  No problem there.

>      <img src="blah.jpg" alt="Blah!">/&gt;

Nope.  YM <img src="blah.jpg" alt="Blah!">&gt;

Look at the parse tree.  Or use Page Valet, which presents the same
results as the W3 validator but in a clearer manner.

-- 
Nick Kew

Received on Monday, 23 September 2002 18:02:41 UTC