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

HTML CAPTION (<caption>) Tag


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>


Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments