Log in

View Full Version : Making <th> align right only on one <th>



tomyknoker
04-11-2007, 10:48 AM
How can I make the <th> on the right hand side align everything inside it to the right? I already have a class which applies to all my <th>



<thead>
<tr>
<th scope="col" class="twentyfive">STATUS</th>
<th scope="col" class="twentyfive">VIEW</th>
<th scope="col" class="twentyfive">DOWNLOAD</th>
<th scope="col" class="twentyfive">TOTAL</th>
</tr>
</thead>

Do I need to add something like this?


table.main thead tr th.twentyfive {
/*border: 1px solid #fff;*/
width: 25%;
}
table.main thead tr th.twentyfive.right {
/*border: 1px solid #fff;*/
width: 25%;
float: right;
}

Twey
04-11-2007, 11:08 AM
You really want to use the :first-child pseudoclass:
thead tr:first-child {
text-align: right;
}Unfortunately, IE (6 at least) doesn't support this pseudoclass, so you have to assign it a new class:
table.main thead tr th.first-twentyfive {
text-align: right;
}
<thead>
<tr>
<th scope="col" class="twentyfive">STATUS</th>
<th scope="col" class="twentyfive">VIEW</th>
<th scope="col" class="twentyfive">DOWNLOAD</th>
<th scope="col" class="twentyfive">TOTAL</th>
</tr>
</thead>