<caption> HTML Tag
In this article I explain the <caption> tag,which is used for creating table captions.
Introduction
The HTML caption
tag is used for creating table captions.The <caption> tag must be inserted immediately after the <table> tag.You can specify only one caption per table.By default, the table caption will be center-aligned above a table.However the CSS properties is used to align the text.
Attributes of <caption> tag
Attribute |
Description |
align |
Specifies the alignment of the caption. |
class |
Specifies a classname for an element |
style |
Specifies an inline style for an element |
id |
Specifies a unique id for an element |
title |
Specifies extra information about an element |
lang |
Specifies a language code for the content in an element |
dir |
Specifies the text direction for the content in an element |
Lets take an example of <caption> tag
<html>
<head>
<title></title>
</head>
<body>
<table width="100" border="2">
<caption>
Student_Rollnumber</caption>
<tr>
<th>
Name
</th>
<th>
RollNumber
</th>
</tr>
<tr>
<td>
Richa
</td>
<td>
1001
</td>
</tr>
<tr>
<td>
Megha
</td>
<td>
1002
</td>
</tr>
</table>
</body>
</html>
|
Output
Student_Rollnumber
Name |
RollNumber |
Richa |
1001 |
Megha |
1002 |
Ask Your Question
Got a programming related question? You may want to post your question here