Welcome to WebmasterWorld Guest from

Forum Moderators: httpwebwitch

Message Too Old, No Replies

XSLT White Space Gaps Under Images

XSLT White Space Gaps Under Images



8:56 pm on Sep 2, 2004 (gmt 0)

10+ Year Member

When transforming an XSLT to HTML I get a very annnoying white space gap of about 2px under each image. This is particularly annoying as I am creating a vertical navigation menu made up of images with rollovers. I know why the space is there, I just dont know how to remedy the problem in my XSLT. The space is caused by the transformed HTML closing </a> being on the next line from the closing </img> tag and the closing </td> on the next line again. Even if I line everything up on the same line in the source XSLT it jumps down again when it is transformed to HTML.

The (simplified) XSLT code is pretty simple:

<xsl:attribute name="href">
<xsl:value-of select="$VirPath" />default.aspx
<img name="ImageName" src="Image.gif>

How can I force the transformed HTML to line up properly so I dont get this 2px gap under my images?


3:06 pm on Sep 3, 2004 (gmt 0)

10+ Year Member

Which xslt processor are you using?


3:30 pm on Sep 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Check your <xml:output> statement. If your output method is "xml" or "html," and you have indent="yes", processors will output the tree as an indented hierarchy, each tag on its own line. The default is supposed to be indent="no".

More fundamentally, why are you including a closing tag for <img>, an empty element? Browsers' methods of handling or ignoring an invalid HTML tag are outside the domain of XSLT.


12:30 am on Sep 4, 2004 (gmt 0)

10+ Year Member

In xsl, you do have to close empty elements also, otherwise the transformation will fail as the processor will burp over it.

I'm not sure about the 2px gap, try the indet if you are doing xml output.


8:48 pm on Sep 5, 2004 (gmt 0)

10+ Year Member

The indent="no" works just fine, problem solved.

Featured Threads

Hot Threads This Week

Hot Threads This Month