Jump to content

What does <tr class="alt"> mean when creating an HTML table


Recommended Posts

alt is the name of the CSS class definition. Check your CSS stylesheet to see what styles are applied for that class.


This is a very simple HTML table. There is no CSS stylesheet.

<table cell spacing = "0" border = "5" style = "width: 20 em; border: 1px solid #567;">
<th>Sequence #</th>
<tr class = "alt">
Link to comment
Share on other sites

you need to have defined the "alt" class in the styles eg

<style type="text/css">
    table {
        border-collapse: collapse;
    tr {
        background-color: #CCCCCC;
    tr.alt {
        background-color: #C0FFC0;
    <table border="1" cellpadding="4" cellspacing="0">
        $c = 'A';
        for ($row=0; $row<6; $row++) {
            $cls = $row%2 ? '' : "class='alt'";
            echo "<tr $cls>";
            for ($col=0; $col<3; $col++, $c++) {
                echo "<td>$c</td>";
            echo "</tr>\n";
Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.