Forum Moderators: open

Message Too Old, No Replies

Images in XHTML tables cause unwanted padding

This happens in FF, looks fine in IE

         

CtrlAltDimension

5:58 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



I am laying out a small design in tables in XHTML Strict.*

When I put an image in a table cell, it adds 3 pixels of padding to the bottom, and sometimes top of the cell. Therefore, my images don't line up.

I've given tr, td, and img all zero padding, borders, and margins in the stylesheet, but I'm still getting the 3px padding.

Is there anything I can do to fix this?

*I am aware that this is bad practice in general, so please don't bug me about that.

encyclo

6:02 pm on Nov 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When in standards-compliance mode (which is the case for XHTML 1.0 Strict) images are inline elements, not block-level elements. Try this in your stylesheet:

table img {
display:block;
}

That should help get rid of the gap under the image.

I love using tables for layout ;)

CtrlAltDimension

7:16 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



Ah! Of course. Thank you, that helped.