HTML td Tag colspan Attribute Tutorial

In this section, we will learn what the colspan attribute is in HTML <td> element and how to use it.

Column Span in HTML Table: What is colspan Attribute in HTML <td> Tag?

The colspan attribute is used to set the width of a table data cell in terms of the number of columns.

For example, if we set the value of this attribute to 2, it means the target cell should take up to two columns of the target table.

HTML colspan Attribute in <td> Tag Syntax:

<td colspan = “number”> </td>

<td> Tag colspan Attribute Values

The value we set for the colspan attribute defines the number of columns the target table data cell should span on.

For example, if the value is set to 3, that means the width of the cell should be wide enough to take on 3 columns.

Example: spanning column in HTML

See the Pen spanning column in HTML by Omid Dehghan (@odehghan) on CodePen.

Leave a Reply