I have a table in HTML which has an associated caption. I want to draw a box around these collectively (a single box around the tabular part and the caption),
caption {
border: 2px solid #eeeeee;
}
table {
border: 4px solid black;
}
<html>
<table>
<caption>Table caption</caption>
<thead>
<tr>
<td>Alpha</td>
<td>Beta</td>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
</tr>
</tbody>
</table>
</html>
I know I could wrap the whole table in a DIV and style that, but I am using another program to generate the HTML programmatically (HTML from markdown using pandoc) so I can't control this. Is there any way to make the black box in the example go all around both the table part and the caption?
If you set the
display
property of the table toinline-block
, then the border of the table will surround both the tabular part and the caption.