View Full Version : Table background images

Sep 3rd, 2007, 09:44 PM
In IE, setting background images for tables doesn't seem to work... whereas in Firefox they do. Is there anyway around this?

Current code:

<tr BACKGROUND='images/whosonline_middle.gif'><td>&nbsp;&nbsp;&nbsp;<span style='background:$colour'><a href='user_lookups.php?username={$userna}'>$userna</a></span> - <span style='background-image: url(images/tagbars/tag_hearts.gif)'><font size='1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$tag</font><br></span></td></tr>";

Sep 4th, 2007, 03:28 PM
Use css.

Sep 5th, 2007, 06:19 AM
Yes I agree, just use CSS.

background:url('yourimage.jpg') repeat-x;

If you don't want your background image to repeat than use:

background:url('yourimage.jpg') no-repeat;

Sep 5th, 2007, 06:24 AM

Internet Explorer browsers will only render table background images if they are defined in the <td> or <table> tags; it will not display background images defined in the <tr> tags.

Just use the code with tr and table tags

<table width="75%" border="1"><tr background="images/backgroundimage.gif><td colspan="3"></td></tr></table>

Also keep in mind that the background image applied to a table cell does not display in Internet Explorer. This issue only occurs if the cells have been combined prior to assigning the background image.

Sep 5th, 2007, 08:49 AM
So put the table inside a div and give the div the background instead.

Sep 5th, 2007, 10:06 AM
Or, if you are using tables to layout your page, read this (http://www.hotdesign.com/seybold/), which will tell you why tables for layout is stupid.