steffi2392
steffi2392

Reputation: 1355

How do I avoid the alternating row color on this HTML table?

I'm using the <table> tag to format some text into rows and columns, but I don't want the rows to alternate colors. For some reason this is happening automatically and I don't know how to turn it off.

Here is my HTML:

<table class="homepage" summary "list of dplans">
<div class="options">
    <ul>
        <% @dplans.each do |dplan| %>
        <tr class ='' "list">
            <td class="button"><%='' link_to dplan.name, dplan %></td>
            <td class="button">
                <%='' link_to "edit name", edit_dplan_path(dplan )%>
            </td>
            <td class="button"><%='' link_to "delete", '#'%></td>
        </tr>
        <% end %>
    </ul>
</div>
</table>

And here is my css:

 td.button {
  font-size: 16px;
  list-style: none;
}

Upvotes: 2

Views: 1259

Answers (2)

Chazbot
Chazbot

Reputation: 1890

I don't think the tag has any styling by default, so chances are there's some other CSS that's causing this. The best way to figure this out is to look at a developer tool like firebug, which can tell you exactly where that background-color is set.

If you just want to override it, you can try something like:

td {
    background:none;
}

Upvotes: 1

Andrei Zisu
Andrei Zisu

Reputation: 4383

First of all, you nested a <div> tag as a child to a <table>. Which is wrong. The only tags permitted for this are <tr>,<th>,<tbody>, etc...

 <table class="homepage" summary "List of dplans">
                    <% @dplans.each do |dplan| %>
                     <tr class = "list">
                      <td class="button"><%= link_to dplan.name, dplan %></td>
                      <td class="button"><%= link_to "Edit name", edit_dplan_path(dplan )%></td>
                      <td class="button"><%= link_to "Delete", '#'%></td> 
                     </tr> 
                    <% end %>
</table>

See if this helps

Upvotes: 0

Related Questions