Use CSS background-image to place a decorative background behind an HTML table or cell. The historical HTML background attribute on <table> and <td> should not be used in modern pages.
<table class="photo-table">
<tr><td>Cell 1</td><td>Cell 2</td></tr>
</table>
.photo-table {
background-image: url("images/bg1.jpg");
background-repeat: repeat;
}
| Cell 1 | Cell 2 |
| Cell 3 | Cell 4 |
Apply a class to a particular <td> when only one cell needs the image. Keep table markup focused on tabular data and presentation in CSS.
Depending on the design, combine background-image with background-repeat, background-position, background-size and a fallback background-color.
A decorative image must not make table text difficult to read. Maintain sufficient contrast and avoid busy images behind important data. Background images also have no useful alternative-text mechanism, so do not use them to communicate essential information.
Original table background demo HTML tables Gradient tutorial
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| andy | 07-12-2014 |
| How can I put different tiling images into a table? I have a 9x9 table, and I want to use the 8 edge cells as the border. I have the corner images sorted (20x20pix), and i have 4 seperate images (20x1 and 1x20) that i need them to extend along the edges. The horizontal ones work, but not the vertical ones. Im using Dreamweaver and CSS. Any suggestions? Thanks | |