How to set horizontal header for a table?

HTMLWeb DevelopmentFront End Technology

Tables in HTML can have horizontal as well as the vertical header. For the horizontal header, you need to set all <th> inside a single <tr> tag i.e. row, that will be the topmost.

Example

You can try to run the following code to set a horizontal header for a table

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
            width: 100px;
            height: 50px;
         }
      </style>
   </head>

   <body>
      <h1>Employee Details</h1>
      <table>
         <tr>
            <th>Name</th>
            <th>Age</th>
            <th>Technology</th>
         </tr>
         <tr>
            <td>Amit</td>
            <td>27</td>
            <td>Database</td>
         </tr>
         <tr>
            <td>Sachin</td>
            <td>34</td>
            <td>Marketing</td>
         </tr>
      </table>
   </body>
</html>
raja
Published on 01-Feb-2018 07:11:02
Advertisements