stevebot
stevebot

Reputation: 24035

Trying to use first-child pseudo class selector

I have the following CSS which isn't working for me.

table.fields tr > td:first-child { padding-right: 50px; }

The HTML is like the following:

    <table class="fields">
         <tbody>
              <tr>
                   <td> text... </td>
                   <td> another td elem... </td>
              </tr>
         </tbody>
   </table>

I want to apply the padding to the first <td> element but not the second.

Upvotes: 0

Views: 443

Answers (2)

JCOC611
JCOC611

Reputation: 19759

As discussed in the comments of the first answer, my lucky guess ended up solving the problem: Use: table.fields tr > tr instead of table.fields tr > td:first-child

P.S: As I said, it might have been worth trying, and it was! Lucky me haha!

Upvotes: 2

BoltClock
BoltClock

Reputation: 724592

This was posted before stevebot fixed the question. Leaving my post here for the sake of its comments.


Your table has no fields class. Change it to this and your CSS selector should pick it up.

<table class="fields">

Upvotes: 3

Related Questions