< Html Tutorial

Html tables

← Previous Next →


Tables are used to organize data "tabular" form i.e. information that is logically presented in rows and columns.

Syntax:

table  - Tag for creating table
th        -  Table head tag
tr         - Defining table row
td        - Defining table column ( table data)

HTML Table Example

Number Name Age
1 Ron 44
2 Snow 15

Code

<table style="width:100%">
  <tr>
    <th>Number</th>
    <th>Name</th> 
    <th>Age</th>
  </th>
  <tr>
    <td>1</td>
    <td>Ron</td> 
    <td>44</td>
  </tr>
  <tr>
    <td>2</td>
    <td>Snow</td> 
    <td>15</td>
  </tr>
</table>


Table with a Border Attribute

the border attribute is used to specify the thickness of the border around your table:

Example

<table border="1" style="width:100%">
  <tr>
    <th>Number</th>
    <th>Name</th> 
    <th>Age</th>
  </th>
  <tr>
    <td>1</td>
    <td>Ron</td> 
    <td>44</td>
  </tr>
  <tr>
    <td>2</td>
    <td>Snow</td> 
    <td>15</td>
  </tr>
</table>

There are lots of attributes for tables. Here are two more:

  • align:  specifies the horizontal alignment of the content in the entire table, in a row or in a single cell. For example, left, center or right.
  • valign:  specifies the vertical alignment of the content in a cell. For example, top, middle or bottom.
← Previous Next →