HTML Table

Create an html table:-

A table is a structured element that consists of rows and columns of cells. You can place any kind of content in these cells like text, images, and even other tables. There are three sets of container tags required to build any table. The <table> and </table> tags define where the table begins and ends, the <tr> and </tr> tags define where each row begins and ends, and the <td> and </td> tags define the individual cells within each row.

HTML Table Tags:-

<table> </table>                      Defines a table

<th> </th>                                 Defines a table header

<tr> </tr>                                   Defines a table row

<td> </td>                                  Defines a table cell

<caption> </caption>               Defines a table caption

Attribute of <table> tag

  • Height                to set the height of table
  • Width                 to set the width of table
  • bgcolor               to set the background color table
  • background      To define a background image for a table
  • cellpadding       to set the space between text and table border
  • cellspacing        to set the space between two cells
  • Border                to set the table border
  • Align                   to set the table alignment

Attribute of <td> tag

  • Bgcolor               to set the background color of specific cell
  • Colspan              to merge two or more columns
  • Rowspan            to merge two or more rows    
  • Align                   to set the table content alignment
Example:

 <html>
<head>
<title>Create Tables</title>
</head>
<body>
    <table border="1">
    <tr>
        <td> 1 </td>
        <td> 2 </td>
        <td> 3 </td>
    </tr>
    <tr>
        <td> 4 </td>
        <td> 5 </td>
        <td> 6 </td>
    </tr>
    <tr>
        <td> 7 </td>
        <td> 8 </td>
        <td> 9 </td>
    </tr>
</table>
</body>
</html>                     

                                                           



Post a Comment

0 Comments