HTML caption tag

By | March 15, 2020

In this chapter we will go into detail about <caption> tag of HTML. HTML <caption> tag is used to append the title of a table table. This tag is used inside a table element. There should be only one caption tag inside a table element. The caption tag is inserted immediately after the table tag.

caption tag Syntax :-

<caption>HTML table title.........</caption>

Caption Attributes:-

Value Attribute Description
left
right
top
bottom
align Not supported in HTML5.
Defines the alignment of the caption

Browser Support:-

All modern browsers support HTML caption tag.

Example:-

<!DOCTYPE html>
<html>
<head>
	<title>HTML caption tag</title>
</head>
  <style>  
        table, td, th {  
        border: 3px solid gray;  
        border-collapse: collapse;}  
    </style>  
<body>
	
	<table>
		<caption>Student Details</caption>
		<thead>
			<tr>
				<th>Student</th>
				<th>Details</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>Student1</td>
				<td>Details1</td>
			</tr>
			<tr>
				<td>Student2</td>
				<td>Details2</td>
			</tr>
			<tr>
				<td>Student3</td>
				<td>Details3</td>
			</tr>
		</tbody>
	</table>

</body>
</html>

Output:-

for job
learn coding
for result in India
Make website make money
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *