Coloring Rows in a Table : tr « Tags « HTML / CSS






Coloring Rows in a Table

    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
  <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1" />
  <style type="text/css">
  .odd {
    background-color: lightgrey;
  }
  
  .even {
    background-color: yellow;
  }
  
  table {
    border: 1px solid black;
    border-spacing: 0;
  }
  
  td {
    padding: 4px 6px;
    border: 1px solid black;
  }
  </style>
</head>
<body>
  <table>
    <tr class="odd">
      <td> Row 1 Cell 1 </td>
      <td> Row 1 Cell 2 </td>
      <td> Row 1 Cell 3 </td>
    </tr>
    <tr class="even">
      <td> Row 2 Cell 1 </td>
      <td> Row 2 Cell 2 </td>
      <td> Row 2 Cell 3 </td>
    </tr>
    <tr class="odd">
      <td> Row 3 Cell 1 </td>
      <td> Row 3 Cell 2 </td>
      <td> Row 3 Cell 3 </td>
    </tr>
    <tr class="even">
      <td> Row 4 Cell 1 </td>
      <td> Row 4 Cell 2 </td>
      <td> Row 4 Cell 3 </td>
    </tr>
    <tr class="odd">
      <td> Row 5 Cell 1 </td>
      <td> Row 5 Cell 2 </td>
      <td> Row 5 Cell 3 </td>
    </tr>
    <tr class="even">
      <td> Row 6 Cell 1 </td>
      <td> Row 6 Cell 2 </td>
      <td> Row 6 Cell 3 </td>
    </tr>
    <tr class="odd">
      <td> Row 7 Cell 1 </td>
      <td> Row 7 Cell 2 </td>
      <td> Row 7 Cell 3 </td>
    </tr>
  </table>
</body>
</html> 

   
    
    
  








Related examples in the same category

1.'tr' Example
2.table row with class
3.Table style for even rows
4.Set different colors for even and odd table row
5.table row background
6.table row hover
7.stripe table with Javascript
8.Selecting cells in row
9.Alternating Row Background
10.Alternating row colors
11.Table with subtotoal row
12.Hiding row
13.tr height: 30px;
14.tr background: #EFEFEF;
15.tr background: url(img/menubg2.gif) repeat-x bottom left #eaeaea;
16.tr color: #505050;
17.tr padding: 7px;
18.tr text-align: left;
19.Highlighting rows with mouse move