table html tag code example

Example 1: table html

<table>
  <thead>
    <tr>
      <th>header1</th>
      <th>header2</th>
      <th>header3</th>
    </tr>
   </thead>
   <tbody>
     <tr>
       <td>text1.1</td>
       <td>text1.2</td>
       <td>text1.3</td>
     </tr>
     <tr>
       <td>text2.1</td>
       <td>text2.2</td>
       <td>text2.3</td>
     </tr>
     <tr>
       <td>text3.1</td>
       <td>text3.2</td>
       <td>text3.3</td>
     </tr>
     <tr>
     </tr>
  </tbody>
</table>

Example 2: html create a table

<html>
 <head>
   <title>Working with HTML Tables</title>
 </head>
 <body>
   <table>				<!-- create an table object -->
     <tr>				<!-- "tr" represents a row -->
       <th>Name</th>	<!-- use "th" to indicate header row -->
       <th>Date of Birth</th>
       <th>Weight</th>
     </tr> 
     <tr>				<!-- once again use tr for another row -->
       <td>Mary</td>	<!-- use "td" henceforth for normal rows -->
       <td>12/13/1994</td>
       <td>130</td>
     </tr>    
   </table>
 </body>
</html>

Example 3: table tag

<table style="width:100%">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>

Example 4: html5 table

<table>
    <thead>
        <tr>
            <th colspan="2">The table header</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>The table body</td>
            <td>with two columns</td>
        </tr>
    </tbody>
</table>

Example 5: table html tages

<table>
  <tr> <!-- This is the first row -->
    <th>This is the heading</th>
    <th>Next heading to the right</th>
  </tr>
  <tr> <!-- This is the second row -->
    <td>This is where the table data goes</td>
    <td>This is the second columns data</td>
  </tr>
</table>

Example 6: html tables

<table></table>
    <td></td> <!-- td is a table cell-->
    <tr></tr> <!-- tr is a table row-->
    <th></th> <!-- th is the table header -->
    <thead></thead><tbody></tbody><tfoot></tfoot> <!-- table semantic -->
    <tr rowspan="2"></tr><!-- Span a row -->
    <tr colspan="2"></tr><!-- Span a column -->

Tags:

Html Example