views:

74

answers:

4

I would like to set the background of a cell in HTML table to be like this.

  • What are my options besides using an image as background ?
  • Are there any predefined backgrounds like this ? Maybe dotted, or diagonal lines backgrounds ?
  • In case of image background, if I don't know in advance what would be the size of the cell, what image size should I take ? How to make it be repetitive so it would look nice ?

Any HTML/CSS/Javascript/jQuery suggestions are welcome :)

+1  A: 

What are my options besides using an image as background ?

There might be something in CSS 3 that has very limited browser support.

In case of image background, if I don't know in advance what would be the size of the cell, what image size should I take ?

The height should be the distance from the top edge of a line to the top edge of the next line. The width should be the distance from the left edge of a line to the left edge of the next line.

How to make it be repetitive so it would look nice ?

background-repeat: repeat; /* this is the default */
David Dorward
+1  A: 

You'll have to use a background image for something like that. To make it tiled, you can use the repeat property in the CSS definition.

td .weird-background { 
    background-image: url('/background.gif');
    background-repeat: repeat;
}
friedo
Thank you very much !
Misha Moroshko
A: 

As far as I know, no way other than using background images. Possibly there is support of that in future versions of CSS though.

Sarfraz
It seems too specific for the css folks to have made an exception -just- for that type of displaying, so I would expect images to be the only solution into the forseeable future.
Tchalvak
@Tchalvak: Possibly but no ones knows about the future. Did we ever think about great functionality offered by CSS3 and HTML5 :)
Sarfraz
Tchalvak
+1  A: 

Since you mentioned that javascript input is welcome, I'll add that you could use javascript to draw on a background canvas.

jQuery Background Canvas Plugin

Mozilla.org Canvas Tutorial

w3.org Canvas API

ghoppe