• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

Style on TD question

My web page uses this piece of code:

<td style="background-image: url('images/backgrd.gif')">

to set a background image on a table's <TD> tag.

The problem is that when trying to print the page, this image does not show. Is there another way of setting a background image on a <TD> or somehow to remedy the problem with not showing on printing?

1 Solution
you have to set your browser to print background colors and images... which i don't believe you can do programmatically.

anyway, to do it in IE, go to tools->internet options->advanced tab: scroll down to Printing and check "Print background colors and images"
Thats correct there is no way to do it code wise   however every browser (that i can think of) allows you to turn on the printing of images and background colors.
yep... thats it... no other way....

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

you can set a background image to <td> tag also like this, and without styles:

<td background="images/backgrd.gif">
There is no way to do so in the code, you can only tell the user to turn it on if they want the bg's printed.

If the printing is vital, you can always use the <img> tag to get the image in the cell.

If it has text over the background, you can add it in an image editor to the image and use the <img> tag.
If you absolutely must have the image print, no matter what the user's settings are, use CSS to absolutely position the image relative to the table cell, and then absolutely position the text over it.

This is the way to do it only if you can't put the text on the image for some reason...which is much easier, as someone above suggested.
if you really want to make that background to show in printing and it doesn't show when on <td> background do it like this.

instead of
<td background='someimage.gif' width='400' height='0'></td>

do it like this: create a new table and put the background there.
<td> <!-- this is the cell you wanted the background on -->
<table border='0' cellpadding='0' cellspacing='0' width='400' height='400' background='someimage.gif'>
   <tr align='left' valign='top'>
      <td>Now your text here =)</td>

the height and width are just example values..

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now