How to create table header in HTML?

HTMLWeb DevelopmentFront End Technology

To create table header in HTML, use the <th>…</th> tag. A table header tag is surrounded by the table row <tr>…</tr>. The <tr> tag is surrounded by the <table> tag. A table consist of a rows and columns, which can be set using one or more <tr>, <th>, and <td> elements. Use the style attribute to add CSS properties for adding a border to the table.

A table row is defined by the <tr> tag. To create table header, use the <th> tag. Just keep in mind that you can only have a single heading in a table.

Example

You can try the following code to create table header in HTML. We’re also using the <style> tag to style the table borders

Live Demo

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

   <body>
      <h1>Database</h1>
      <table>
         <tr>
            <th>Database</th>
            <th>Release Year</th>
         </tr>
         <tr>
            <td>MySQL</td>
            <td>1995</td>
         </tr>
      </table>
   </body>
</html>
raja
Published on 01-Feb-2018 06:48:37
Advertisements