By default, the table caption is placed on top of the table block (top), but the caption-side property allows it to be placed below the table (bottom). Table captions are block elements, but they have some peculiarities. Figure 22-2 shows the relationship of the caption to the table body.

Figure 22-2. Table and caption
As block elements, they can be given their own properties, such as margins. However, they are also treated as children of the table element, and therefore will inherit properties applied to the table. So although it occupies a separate block with its own margins, if the color of the table is set to blue, the caption will be blue as well.
The margins between the caption and table block collapse to equal the greater specified value.
There is an implied or (anonymous) box that encloses the table box and the caption box. It is this anonymous box that is used when the table element is positioned with properties such as float, position, margin-*, top, right, bottom, or left.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access