How to use caption tag in html | caption tag code | HTML

HTML CAPTION (<caption>) Tag

by Jai 04-Jun-19

0 1217

HTML <caption> tag is used  in conjunction with table tag to add the caption /title of an HTML table. It should be used inside table tag i.e. just after the <table> start tag. One table can contain only one <caption> element.

A table caption will be aligned center by default above a table. But the user can modify its place through CSS properties. The <caption> tag is written as <caption></caption> with the caption content inserted between the start and end tags.


<!DOCTYPE html>
<title>The Caption Tag</title>
table, td, th {
border: 2px solid gray;
border-collapse: collapse;}
<h2> Example of Caption Tag </h2>
<table width="450">
<caption> Random Details </caption>
<th> Sr. No. </th>
<th> Name </th>
<th> Email </th>
<td> 1. </td>
<td> Jai </td>
<td> </td>
<td> 2. </td>
<td> Lalita </td>
<td> </td>
<td> 3. </td>
<td> Codinguser </td>
<td> </td>


HTML CAPTION (<caption>) Tag


Leave a Reply

    Waiting for your comments