Search DaTutorials:  
HOME
Html Tutorials
Basics
Forms
Frames
Hyperlinks and URLS
Images
Lists
Background
Colors
Fonts
Tables
Meta Tags
Events
Javascript Integration
Sound
Other
Search For a Tutorial
Html Reference

Set table's background color or background image

Description:


How to make background color or background image in a table.

Code:

<html>
<body>


<h4>Background image</h4>
<table border="1" background="Tilt.jpg">
<tr>
  <td>cell 1</td>
  <td>cell 2</td>
</tr>
<tr>
  <td>cell 3</td>
  <td>cell 4</td>
</tr>
</table>


<h4>Background color</h4>
<table border="1" bgcolor="pink">
<tr>
  <td>cell 1</td>
  <td>cell 2</td>
</tr>
<tr>
  <td>cell 3</td>
  <td>cell 4</td>
</tr>
</table>


</body>
</html>

Play with the code:

See working example:


Explanation:

To set the table's background color, use the attribute bgcolor of the <table> tag. Set its value to the name of the color: blue, red, orange, white, yellow,... or set it to its hexadecimal value like this: #00FF00, #CCFFDD, #000000, ..... You can also set the color in its RGB value, like this: RGB(10,255,0) for example.

To set an image as a table's background, use the background property of the <table> tag. Set the property value to the path of the image you want to load as a table's background.

See Also:

HTML: Html, Body, Table, Tr, Td


Online Html Forum  Discuss this tutorial in our HTML forum


     Loans | Free online video sharing India | Mortgage Calculator | Moneygram | Credit Cards
Home     Link To Us     Ad With Us     Contact Us     Tell A Friend     Affiliates     Blog     MsOfficeHelp