views:

25

answers:

3

Hello,

I am working on e-mail template

Code is something like this :

<table width="702" cellpadding="0" cellspacing="0" align="center" id="template">
<tr>
<td align="left" valign="top">
<img src="/email/new/top_bar.png" width="702" height="11" alt="" border="0">
<img src="/email/new/bottom_bar.png" width="702" height="11" alt="" border="0">
</td>
</tr>    
</table>

I always get vertical Whitespace between these two images.

I tried using valign, vspace but no luck.

How to get ride of it?

Thanks

+1  A: 

Strange: This shouldn't be.

Maybe the E-Mail client interprets the line break in between the <img>s as white space.

Try setting them directly next to each other: <img src...><img src...

Pekka
A: 

You get whitespace because the images are laid out inline (between two rows of lines there is spacing). You can either lay them out as block elements....

img { display:block; }

.. or you can use the vertical-align property to define a different vertical align which should remove the spacing...

img { vertical-align:top; }

http://vidasp.net/media/CSS-vertical-align.gif

BTW, please stop using deprecated attributes (cellpadding, cellspacing, align, border). For each of those attributes there is a CSS alternative which should be used. Also, use some CSS reset code (like Yahoo CSS Reset)...

Šime Vidas
@Šime he is building an E-Mail where there still is no way around those attributes, as CSS support is very shaky
Pekka
Hey! your answer display:block worked perfect. Thanks! I am working on Email templates and 90% email clients only understand cellpadding, cellspacing, align, border.. they dont know css3 and html5 yet.
MANnDAaR
Replacing the HTML attributes with CSS has been around for a long time and it is not related to CSS 3. I don't know much about HTML e-mails, but if you can use the STYLE element to put CSS inside, then you should be able to use the padding, border, text-align, vertical-align and other CSS 2.1 properties... (of course, only if those properties are supported, you have to check)
Šime Vidas
True! but most of the Email clients only understand inline CSS and that is very limited properties works. Have a look here : http://www.campaignmonitor.com/css/
MANnDAaR
Oh man. And I thought that cross-browser compatibility for desktop browsers is challenging. Good luck getting uniform presentation in all those clients :)
Šime Vidas
MANnDAaR
A: 

Your lines are high enough to accommodate text in the default font, which is higher than your 11 pixel images, hence the gap.

You need to make the lines smaller; the simplest way for your example is to shrink the font:

<td style="font-size: 1px;" align="left" valign="top">

Tested in IE 8, Firefox 3.6 and Chrome 6.

RichieHindle