Incorporating CSS, I have managed to style my rows in alternating colors. Take a look at the code snippet below: Fiddle
tr:nth-child(odd) td { background-color:red; }
tr:nth-child(even) td { background-color:blue; }
tr th { background-color: yellow}
table {
border: 1px solid black;
margin: 10px;
width: 100px;
}
There's an issue when it comes to tables with headers - the header row is counted as the first row, causing the data to start with blue instead of red. Is there a way to ensure that the data always starts with red regardless of whether a table has a header or not?