What is the <caption> element in html?

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.

Syntax

Opening and closing tags are required to show captions. The syntax is shown below:

<caption>Caption content</caption>

Attributes

<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

Code

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.

  • HTML

Free Resources