Set different colors for even and odd table row : table row : Table Style HTML CSS TUTORIALS


HTML CSS TUTORIALS » Table Style » table row »

 

Set different colors for even and odd table row


 

<!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>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
td {
  background-color: #FFFFCC;
}
table {
  width:25%;
  border-collapse:collapse;
}
tr.grey td {
  background-color: #CCCCCC;
}
</style>
</head>

<body>
<table>
  <tr> 
    <td>Some text</td>
    <td>Some more text</td>

    <td>&nbsp;</td>
  </tr>
  <tr class="grey"
    <td>Hello</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td>&nbsp;</td>

    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr class="grey"
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td>&nbsp;</td>

    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

 



HTML code for linking to this page:

Follow Navioo On Twitter

HTML CSS TUTORIALS

 Navioo Table Style
» table row