In HTML, the <caption>
tag is used to display the caption of an image, table, or whatever you want. The content between caption elements is center-aligned by default.
Opening and closing tags are required to show captions. The syntax is shown below:
<caption>Caption content</caption>
<caption>
supports multiple attributes. <caption>
also accommodates global attributes.
The description of attributes that are specific to the <caption>
tag are below:
Attribute | Description |
---|---|
align : top, bottom, center, right, and left |
It will show captions according to the aligned value |
The code snippet below shows the caption of a table that has two rows and two columns. It tells us the name and profession of the person. In line 6, we use the <caption>
tag, which demonstrates the alignment of <caption>
at the bottom.