f855a864 f855a864 - 6 days ago 5
HTML Question

How to make table's width fixed

I have two tables inside a table :

<table>
<tbody>
<tr>
<td class="tdkqtb">
<table border="1">
<tbody>
<tr>
<th>Giải</th>
<th>@cityID</th>
</tr>
</tbody>
</table>
</td>

<td class="tdkqtb">
<table border="1">
<tbody>
<tr>
<th>Đầu</th>
<th>Đuôi</th>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
</tbody>

</table>


enter image description here

Now I need to set the width of the two tables fixed. How can I do that? For example I want all tables to have the same width as the first twos. I mean they must have a fixed width for each column, the first table will contains 70% width of the parent table, and the second contains the rest. The columns in the two tables must have fixed width too!

Answer

Not sure if I understood what you want but you can just select the required element of the table or the whole table and give a width in css

table {
    width: 70%;
}

If you have multiple tables, give them ids or classes to seperate for different styles. Same for the th, tr, td and so on.

Comments