Set width and height to auto for table in HTML and CSS

Description

The following code shows how to set width and height to auto for table.

Example


<!--from   w  ww .  ja va2s  .  co m-->




<html>
<head>

<style type='text/css'>
table {
border: thin solid black;
width: auto;
height: auto;
}
</style>
</head>
<body>
<table>
<tr>
<td>
The table only expands enough for the content inside of it.
</td>
</tr>
</table>
</body>
</html>

Click to view the demo

The code above generates the following result.

Set width and height to auto for table in HTML and CSS