Table Background To Style HTML Tables Is Out (But CSS Is In)
Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
- Attribute of
- Create An HTML Table Quickly & Easily With Our Code Example
- What does
Table Background To Style HTML Tables Is Out (But CSS Is In)
do? - Was used to specify the URL of an image to be set as the background for an HTML table. This element has been deprecated. Use CSS to style HTML tables.
Code Example
<table background="/wp-content/uploads/wov.png">
<tr><td>First column</td><td>Second column</td><td>Third column</td></tr>
<tr><td>First column</td><td>Second column</td><td>Third column</td></tr>
<tr><td>First column</td><td>Second column</td><td>Third column</td></tr>
</table>
First column | Second column | Third column |
First column | Second column | Third column |
First column | Second column | Third column |
Adding a Background Image to a Table
The background
attribute was used to specify a URL where an image file could be found. The browser would use that image as a background image for the table
element to which the background
attribute had been applied.
This attribute has been deprecated in favor of styling tables with CSS.
To apply a background image with CSS, use the background
property.
<style>
table.example-table {
background: url("/wp-content/uploads/wov.png");
/* image courtesy of subtlepatterns.com */
}
</style>
<table class="example-table">
<tr><td>First column</td><td>Second column</td><td>Third column</td></tr>
<tr><td>First column</td><td>Second column</td><td>Third column</td></tr>
<tr><td>First column</td><td>Second column</td><td>Third column</td></tr>
</table>
Here’s how the browser interprets that bit of code.
table.example-table{background: url(“/wp-content/uploads/wov.png”); /* image courtesy of subtlepatterns.com */}
First column | Second column | Third column |
First column | Second column | Third column |
First column | Second column | Third column |