How to load a background image for entire space of pat of the Web page


I want to load a background image into part of the Web page, so that the background image auto resizes to fill the entire space of the cell.
But not the spaces above or below the cell that should have the background image.
A good example is like
That is I want to have the Top Navigation bar & Footer Navigation bar, to have no background image. But the background image to cover the
entire space of the Table Cell between the Top Navigation bar & Footer Navigation bar.
How does one do this?


It’s easy these days, using the background-size property. For example, you can get a background image to cover an element with

element {
  background-size: cover;

However, I don’t know if this works on table cells, and I dare say a table is not what you should be using here.


How/Where do I specify the background image file path (src) in above code?

This is the basic setup:

element {
  background-image: url(/images/bg.png);
  background-size: cover;


It is working OK.
You can see it here:


Great! I do wish you’d lose the table, though. :wink:

Hi Ralph,

Actually I have a follow up question. Well 2 actually.

1- How would one make the background image change every X Seconds by gently sliding to right or left ?

2- How would one upload a new background image by user clicking on a next button? Of course load the new background images without going to the server but have them seamlessly loaded from client side.



Are you talking about an image slider?

Something like this perhaps. There are quite a few around.

Yes, as Paul says, there are tons of these around. Most use inline images rather than background images, although that can be changed. Here is one that seems to use bg images out of the box:

Still, this is a trickier area, and a gallery like this won’t play nicely with tables, I’d think.