html tutorial - colspan Attribute in HTML - html5 - html code - html form



Colspan attribute in html

Learn html - html tutorial - Colspan attribute in html - html examples - html programs

  • The colspan attribute is used to specify the number of columns to span.
  • The colspan attribute can be applied on the <td> and <th> tag.

Syntax for colspan attribute in HTML:

<td colspan ="number">content </td>

Applies To:

Elements Attribute
<td> colspan
<th> colspan

Value of colspan attribute in HTML:

Value Description
value Sets the number of columns the cell should span.

Sample Coding for colspan Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
<body>
        <head>
        <title>Wikitechy HTML colspan attribute</title>
        </head>
        <table border=1>
        <tr>
        <th>Firstname  </th>
        <th>Lastname  </th>
        </tr>
        <tr>
        <td colspan="2">Wikitechy </td>
        </tr>
        </table>
 </body>
 </html>

Code Explanation for colspan Attribute in HTML:

  colspan Attribute Code Explanation

  1. <table> tag - is used to define the data in the table format that will be shown with a border.
  2. <td>tag - used to define data in the cell.
  3. colspan attribute is used to combine the two cells into single cell.

Output fo colspan Attribute in HTML:

  colspan Attribute Tag Output

  1. The output shows the Wikitechy in the single column using the colspan attribute.

Browser Support for colspan Attribute in HTML:

Yes Yes Yes Yes Yes

Related Searches to colspan Attribute in html