How to create tables in HTML?


To create table in HTML, use the <table> tag. A table consist of rows and columns, which can be set using one or more <tr>, <th>, and <td> elements. A table row is defined by the <tr> tag. To set table header, use the <th> tag. For a table cell, use the <td> tag.

Just keep in mind, table attributes such as align, bgcolor, border, cellpadding, cellspacing deprecated and isn’t supported by HTML5. Do not use them.

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

Example

Live Demo

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

   <body>
      <h1>Programming Languages</h1>
      <table>
         <tr>
            <th>Language</th>
            <th>Release Year</th>
         </tr>
         <tr>
            <td>Java</td>
            <td>1995</td>
         </tr>
         <tr>
            <td>Pascal</td>
            <td>1970</td>
         </tr>
      </table>
   </body>
</html>
raja
Published on 01-Feb-2018 06:45:24
Advertisements