skiller185
skiller185

Reputation: 55

How can I format every element within a table?

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            .linktabledesign tr td a{
                .
                .
                .
            }
        </style>
    </head>
    <body>
        <table>
            <tr>...</tr>
            <div id="stuff" class="linktabledesign">
                <tr>
                    <td><a></a></td>
                    .
                    .
                    .
                    <td><a></a></td>
                </tr>
                .
                .
                .
                <tr>
                    <td><a></a></td>
                    .
                    .
                    .
                    <td><a></a></td>
                </tr>
            </div>
        </table>
    </body>
</html>

I'd like to format each of the <a> tags within the <div> with id="stuff" with the class linktabledesign. I have set my code up as seen above (leaving out the data). What error have I made to prevent my code from working as I intended?

Upvotes: 2

Views: 36

Answers (1)

Blazemonger
Blazemonger

Reputation: 92893

div is not a valid child element of table. Try using thead, tbody and tfoot instead.

.linktabledesign tr td a {
  color: green;
}
<table>

  <thead>
    <tr>
      <td>
        <a>head link</a>
      </td>
    </tr>
  </thead>

  <tbody class="linktabledesign">
    <tr>
      <td>
        <a>body link</a>
      </td>
      . . .
      <td>
        <a>body link</a>
      </td>
    </tr>
  </tbody>

  <tfoot>
    <tr>
      <td>
        <a>footer link</a>
      </td>
    </tr>
  </tfoot>

</table>

Upvotes: 3

Related Questions