Striping Tables

Striping tables means to set each alternate row in a table to a different colour to make it more readable.

Using jQuery

For example:

<table class="striped" style="width: 101px; height: 104px;" border="0" cellpadding="3">

To colour the above table the following code was used:

<script language="JavaScript" type="text/javascript">
         jQuery('.striped tr:even').addClass('evenrow');
         jQuery('.striped tr:odd').addClass('oddrow');

The ".striped" class ensures that only the table with class "striped" is affected. This is especially important in Joomla as pages are often constructed using tables from the template.


Now that CSS3 is out striping can be done without any Javascript.

.table-striped > tbody > tr:nth-of-type(2n+1) {
  background-color: red;


Bootstrap also does striping easily. If you are using it the classes "table table-striped" will do the stripe effect for you. More table effects can be seen here.

Leave a Reply

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram