Aligning and Positioning Captions - HTML

CSS can also help control the positioning of table caption elements. The positioning of the caption is controlled by the caption-side property. This property has the following format:

caption-side: top | bottom | left | right;

The value of the property determines where the caption is positioned in relationship to the table. To align the caption in its position, you can use typical text alignment properties such as text-align and vertical-align.
For example, the following code places the table’s caption to the right of the table, centered vertically and horizontally.

Positioning a caption to the right of a table.

Positioning a caption to the right of a table.

Note that the table’s caption is positioned inside the table’s margin. By increasing the margin of the table, you allow more text per line of the caption. You can also explicitly set the width of the caption using the width property, which increases the margins of the table accordingly.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

HTML Topics