Re: Leading spaces inside of a tag?

It seems no one responded, so I would try ...

Joseph Pingenot <jap3003@ksu.edu> wrote:

> I had a page validate as HTML 4.01, but have a space between the <
>   and the img.  That is, I had (approximately):
>   < img src="blar.jpg">
>   validate.  However, it refused to render under any browser available
>   to me (IE 6, Mozilla 0.9.3, and Netscape 4.78).  Is whitespace
>   allowed between the leading < and the tag text, or is it a validator
>   bug?

White space is not allowed between the leading < (a.k.a. STAGO in SGML
terminology) and the element name, however, this is NOT a validator bug.

In SGML, when < is not followed by name characters, < is not treated as
STAGO but just character data, so in your example, `< img src="blar.jpg">'
is not treated as markup but as character data `<', a white space and
the text string `img src="blar.jpg">'.  So long as #PCDATA is allowed
there in a specified DTD, it just validates, but the result will not be
what you intended, as browsers (correctly) rendered them as just text
string.

Note that in XML, when < is not used for markup, it must always be
escaped, so (pseudo) markup like `< img src="blar.jpg"/>' will cause
a well-formedness error.

Hope this helps.

Regards,
-- 
Masayasu Ishikawa / mimasa@w3.org
W3C - World Wide Web Consortium

Received on Sunday, 9 September 2001 17:33:49 UTC