0

Hello,

I would like to style my table. I have two different table that I would like to style differently. How to do so?

This is what I try but it does not work:

table, td {
    padding: 5px;
}

 .order table, td{
    width: 5px;
}
</style>

<table class="order" border="1">
  <tr>
    <th>Nama Produk</th>
    <th>Harga</th>  
    <th>Jumlah Pembelian</th>  
    <th>Tipe Produk</th>  
    <th>Total</th>          
  </tr>
  <tr>
    <th><input type="text" name="fname"></th>
    <td><input type="text" name="fname"></td>
    <td><input type="text" name="fname"></td>
    <td><input type="text" name="fname"></td>
    <td><input type="text" name="fname"></td>
  </tr>

</table>

One table order I would like to set the width : 5px.

Please help. Thanks in advance.

5
Contributors
5
Replies
28
Views
1 Week
Discussion Span
Last Post by BinaryDigit
0

Tables by default strech to fill up the provided space

Also Google cell-padding is I believe the correct attribute to use

0

The cellpadding attribute has been dropped, the suggested method these days is to use padding: val in css.

0

pty is right. Your CSS selectors don't make any sense.

You gave that table a class order, so target the td of that table properly like so:

.order td {
    width: 5px;
}

But Like pty said... what the heck do you want to display in a 5px width table cell? :)

Edited by gentlemedia

1

You should keep your styles in the class, then apply that class to your table. Don't style table or td directly. You might want to use a table or td elsewhere in the page that doesn't use that styling (so in that case, create a different class and style).

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.