Table in HTML 5

Introduction

 
The table is used to display some data in a tabular, rows and columns format. 
 
Syntax for creating the table is given below
  1. <table>  
  2.     <tr>  
  3.         <th>Table_Header1</th>  
  4.         <th>Table_Header2</th>  
  5.     </tr>  
  6.     <tr>  
  7.         <td>Cell_One</td>  
  8.         <td>Cell_Two</td>  
  9.     </tr>  
  10. </table>  
Here, <table> tag defines the Table, <tr> tag defines Table Row, <th> tag defines Table Header(Column Header) and <td> tag defines Table Column.
 
Now, we use these code to create a table by writing the following code
  1. <!DOCTYPE HTML>  
  2. <html>  
  3.     <head>  
  4.         <table>  
  5.             <tr>  
  6.                 <th>Name</th>  
  7.                 <th>Subject</th>  
  8.             </tr>  
  9.             <tr>  
  10.                 <td>A. Kumar</td>  
  11.                 <td>HTML</td>  
  12.             </tr>  
  13.             <tr>  
  14.                 <td>B. Kumar</td>  
  15.                 <td>.NET</td>  
  16.             </tr>  
  17.         </table>  
  18.     </body>  
  19. </html>  
When we run this code, the output will look like below:
 
table in html 5
 
We can change the width of the table by assigning value to it. As below code
  1. <table width=100%>  
We can also set border thickness and height by assigning value to it. Like below code
  1. <table width=100height=70px border=4>  
We make some changes in the above code by assigning value to width, height, and border attributes. Now, the code is as below
  1. <!DOCTYPE HTML>  
  2. <html>  
  3.     <head>  
  4.         <table width=100height=70px border=4>  
  5.             <tr>  
  6.                 <th>Name</th>  
  7.                 <th>Subject</th>  
  8.             </tr>  
  9.             <tr>  
  10.                 <td>A. Kumar</td>  
  11.                 <td>HTML</td>  
  12.             </tr>  
  13.             <tr>  
  14.                 <td>B. Kumar</td>  
  15.                 <td>.NET</td>  
  16.             </tr>  
  17.         </table>  
  18.     </body>  
  19. </html>  
When we run the code with these changes, the output will look like the below figure:
 
 table in html 5