Horje
How to create HTML Header for Multiple Columns

You can have a header that spans over two or more columns.


Basic Example of HTML Header for Multiple Columns

 <table>
  <tr>
    <th colspan="2">Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table> 

Full Example of HTML Header for Multiple Columns

To do this, use the colspan attribute on the <th> element:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
</style>
</head>
<body>

<h2>A header that spans two columns</h2>

<p>Use the colspan attribute to have a header span over multiple columns.</p>

<table style="width:100%">
  <tr>
    <th colspan="2">Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>
</body>
</html>

Output should be:

Full Example of HTML Header for Multiple Columns





Related Articles
What is HTML Table Headers HTML Table Headers
How to create Table Headers in HTML HTML Table Headers
How to create HTML Vertical Table Headers HTML Table Headers
How to create HTML Align Table Headers HTML Table Headers
How to create HTML Header for Multiple Columns HTML Table Headers
How to create HTML Table Caption HTML Table Headers

Single Articles
Basic Example of HTML Header for Multiple ColumnsHTML Table Headers
Full Example of HTML Header for Multiple ColumnsHTML Table Headers

Read Full:
HTML Table Headers
Category:
Web Tutorial
Sub Category:
HTML Table Headers
Uploaded:
1 year ago
Uploaded by:
Admin
Views:
48


Reffered: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_th_colspan

Share on: