Summary -

In this topic, we described about the <col> tag along with detailed example.

Specifies one or more column in a table. The <col> tag is used to represent one or more columns. <col> tag will be used to apply different attribute values across one or more columns, but not all columns. <col> tag has no data, so no ending tag required.

The tag can be coded like <col span="">. The <col> tag should be used within a colgroup element if doesn’t have span attribute. Most of the attributes <col> tag in HTML 4.01 are not supported in HTML5. The <col> tag is useful for applying styles to entire column.

Syntax -

<col>.... HTML text here </col>

Optional Attributes -

Attribute Description Values
align Specifies the <col> content alignment.Not supported in HTML5 leftrightcenterjustifychar
Char Specifies the <col> content alignment to character.Not supported in HTML5 Char
span Specifies the number of columns the col element needs to be applied. Number.
Valign Specifies the <col> content virtual alignment.Not supported in HTML5 BaselineBottomMiddletop
Width Specifies the <col> content width.Not supported in HTML5 Pixels%

Example -

<!DOCTYPE html>
		<title> Code formatting element example.. </title>
			<caption>Employee details</caption>
				<col class="column1">
				<col span="1" class="columns2">
				<th>EMP name</th>

Output -

Employee details
EMP name Designation
Pawan Lead