Html Make a Div Not Longer Than Its Content
Html Make a Div Not Longer Than Its Content
Published
Html Make a Div Not Longer Than Its Content
If you want the div to only expand to as wide as the table.
<table>
<th>
<td>ID</td>
<td>Name</td>
<td>class</td>
</th>
<tr>
<td>1</td>
<td>James</td>
<td>2nd</td>
</tr>
</table>
The solution is to set your div to display: inline-block. The effect is called “shrinkwrapping”
div {
display: inline-block;
}