Summary -

In this topic, we described about the <caption> tag along with detailed example.

Used to specify the caption or title for a table. The <caption> tag is used to define table captions. If the <caption> tag used with table, it would be the first tag before any other table tag.

The caption can be as long as like paragraph or short titles. Any text inserted in between <caption></caption> will be treated as caption for the tag.

Only one caption needs to be associated with table, but not more than one. The align attribute was removed from HTML5.

Syntax -

<caption>.. text here.. </caption>

Optional Attributes -

Align Specifies the caption alignment.Not supported in HTML5 LeftRightTopbottom

Example -

<!DOCTYPE html>
		<title> Caption element example.. </title>
			<caption>Employee details</caption>
				<th>EMP name</th>

Output -

Employee details
EMP name Designation
Pawan Lead