HTML col tag

By | March 17, 2020

In this chapter we will read about and understand the tag <col> of HTML In the HTML column, <col> tags of the HTML are used to specify the normal column property for each column within <colgroup> element. This tag applies only if the normal style rule is applied to each column cell.

HTML col tag Syntax:-

<col span="" style="">

Browser Support:-

All modern browsers support this tag of HTML.

Attributes:-

Value Attribute Description
left
right
center
justify
char
align Not supported in HTML5.
Specifies the alignment of the content related to a <col> element
character char Not supported in HTML5.
Specifies the alignment of the content related to a <col> element to a character
number charoff Not supported in HTML5.
Specifies the number of characters the content will be aligned from the character specified by the char attribute
number span Specifies the number of columns a <col> element should span
top middle
bottom
baseline
valign Not supported in HTML5.
Specifies the vertical alignment of the content related to a <col> element
%
pixels
relative_length
width Not supported in HTML5.
Specifies the width of a <col> element

Example:-

<!DOCTYPE html>
<html>
<head>
	<title>HTML col tag</title>
	<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>  
<body>

<table>

<colgroup>
	<col span="2" style="background-color: #ccc;">
	<col style="background-color: red;">
</colgroup>

	<tr>
		<th>Name</th>
		<th>Roll No.</th>
		<th>Maths</th>
		<th>Science</th>
	</tr>
	<tr>
		<td>First Name</td>
		<td>10</td>
		<td>89</td>
		<td>80</td>
	</tr>
	<tr>
		<td>Second Name</td>
		<td>11</td>
		<td>90</td>
		<td>70</td>
	</tr>
</table>
	

</body>
</html>

Output:-

for job
learn coding
for result in India
Make website make money

Leave a Reply

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