w3resource

HTML span attribute

span

The purpose of the HTML span attribute is to specify the how many columns of a given col or colgroup will be affected.

Supported elements

HTML span attribute supports col and colgroup elements.

Syntax

<ElementName span="value" >.....</ElementName>

Where ElementName is any supported element.

Type of value

Must be an integer greater than zero.

Value

An integer greater than zero indicating a number of columns of a table.

Default value

Default value of HTML span attribute is 1.

Supported doctypes

HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.

Example of HTML span attribute with col element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML span attribute with col element</title>
</head>
<body>
<table width="100%" border="1">
<col span="3" align="center">
<tr>
<th>Name</th>
<th>Designation</th>
<th>Salary</th>
</tr>
<tr>
<td>Subroto Dey. </td>
<td>Regional head, Sales </td>
<td>$1500</td>
</tr>
</table>
</body>
</html>

Result

html span attribute with col element

View this example in a separate browser window

Example of HTML span attribute with col element

Example of HTML span attribute with colgroup element

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML span attribute with colgroup element</title>
</head>
<body>
<table width="100%" border="1">
  <colgroup span="2"></colgroup>
<tr>
<th>Name</th>
<th>Designation</th>
<th>Salary</th>
</tr>
<tr>
<td>Subroto Dey. </td>
<td>Regional head, Sales </td>
<td>$1500</td>
</tr>
</table>
</body>
</html>

Result

html span attribute with colgroup element

View this example in a separate browser window

Example of HTML span attribute with colgroup element

Previous: HTML size attribute
Next: HTML src attribute