RE: [xslt] whitespace around IMG tag



What IE is doing is appropriate. It sees white space in element context, so
it renders it. White space between attributes in a tag will be ignored, and
multiple white space characters in content are compressed to a single space
(except in <PRE> elements, I think), but otherwise white space is rendered.
(Note that this is a simplification; see the spec for the complete rules.)

The bottom line, though, is simple: unless you want white space rendered,
don't include it.

Are you saying that the following HTML does not result in whitespace being
rendered?

<div>
<img>
</div>

If so, that seems wrong. Furthermore, I'd expect whitespace before and after
the image, not just after. For what it's worth, I tend to rely on Mozilla's
interpretation of the standards, because it seems to have the best and most
complete (though still not perfect) implementation.

> -----Original Message-----
> From: Novický Marek [mailto:novicky@aarongroup.cz]
> Sent: Wednesday, June 04, 2003 10:29 AM
> To: xslt@gnome.org
> Subject: [xslt] whitespace around IMG tag
> 
> 
> Hi All,
> 
> I'm running into trouble when using HTML output with INDENT turn on.
> 
> A template 
> 
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="html" indent="yes" />
> <xsl:template match="/">
> <html>
> <body>
> <div><img /></div>
> <div><img /><img /></div>
> <div><img /><img /><img /></div>
> </body>
> </html>
> </xsl:template>
> </xsl:stylesheet>
> 
> would produce following output:
> 
> <html><body>
> <div><img></div>
> <div>
> <img><img>
> </div>
> <div>
> <img><img><img>
> </div>
> </body></html>
> 
> The problem is that IE takes those newline between <img> and 
> </div> as a textnode, rendering some extra space around image.
> 
> I know that similar problem has been discussed before and it 
> works fine when using a single <img> (inline) tag inside 
> <div>, <td> and other block tags.
> 
> I also know I can turn off indenting in output, which helps.
> 
> I wonder, whether this behavior is correct and if yes, 
> whether is there any other workaround to solve the problem.
> 
> Thanks
> 
> Marek 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]