tables in html can have horizontal header and vertical header. for the horizontal header, we need to set all

语法
以下是设置表格水平标题的语法:
<tr> <th> horizontal header1… </th> <th> horizontal header2… </th> </tr>
Example 1
的中文翻译为:
示例 1
Now let us see an example program to set horizontal header for a table.
<meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><style>
table,tr,th,td {
border:1px solid black;
padding: 20px;
}
</style><h2>Tables in HTML</h2>
| First Name | Job role |
|---|---|
On executing the above program, it will display a table with horizontal headers First Name and Job role.
Example 2
现在,在这个第二个示例中,我们尝试创建另一个具有水平标题“Name”、“Age”和“Technology”的3行示例 −
<style>
table, th, td {
border: 1px solid black;
width: 100px;
height: 50px;
}
</style><h1>Employee Details</h1>
| Name | Age | Technology |
|---|---|---|
| Amit | 27 | Database |
| Sachin | 34 | Marketing |
Following is the output for the above example program.
Example 3
我们还可以为表格设置垂直标题。下面是一个示例,用于创建表格的垂直标题。
<meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><style>
table,tr,th,td {
border:1px solid black;
padding: 20px;
}
</style>
| First Name | ||
|---|---|---|
| Last Name | ||
| Job role |
Following is the output for the above example program.











