HTML Tables

HTML Tables

HTML Tables are used to organize information into rows and columns.

In HTML tables you can arrange data such as text, images or links. Using Tables you can get better formatting of data.

List of Table Tags
Attribute Description Syntax & Example
Table Tag Used to define table. All other table tags and data placed within Table tag. <table></table>
Table Heading Used to define table heading row. Mostly used for first table row. <th></th>
Table Row Used to define each table row. <tr></tr>
Table Data Used to define table data in cells <td></td>

Example of Simple HTML Table:

HTML Table is created using <table> tag. All other table tags are placed under this tag.

First row often contains heading in tables. A row starts with <tr> tag and then each heading is created using <th> tag for each column.

Then we create another row for data. Again, A new row starts with <tr> tag while data is created using <td> tag for each column.


HTML Table Tag & Attributes

You can make some changes in Table styles using given attributes.

For example, above simple html table program have a border attribute that draws border around the table. Here, is the list of common table attributes.

HTML Table Attributes
Attribute Description Syntax & Example
Border used to specify border around the table & cells border=“2”
Cell Padding specify amount of spacing between cell border and cell content. cellpadding=“5”
Cell Spacing specify amount of spacing between two adjacent cells. cellspacing=“3”
Width used to set the width of the table. width=“80%”
align used to set the alignment of table horizontally. align=“centre”
bgcolor used to set the background color of the table. bgcolor=“blue”
background used to set image in the table background. background=“image.jpg”

Example using Table Attributes

Here is a simple example using various table attributes.


Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top