HTML Page Structure

HTML Elements
HTML Attributes


HTML Table Tag

HTML Table Tag is used for arranging the data in the form of rows and columns on the web page. It is a very useful feature. One another purpose of using a table is to create a page layout with the use of hidden tables.

Table can be created using <table> element in HTML. Alongwith table element, other elements used are <tr> which refers to a table row, <th> which refers to a table header and <td> which refers to a table cell/column.

Syntax

Example

This will produce following result

Name Subject Marks
John History 79

Table Attributes List

The below table contains Table Attributes and their description which is supported by HTML version.

Attribute NameAttribute ValueAttribute Description
border0 or 1refers to whether the table cells have border or not
bgcolorcolor-namerefers to background color of the table
cellpaddingpixelsrefers to spacing between cell's wall & content
cellspacingpixelsrefers to spacing between cells
widthpixels or %refers to width of a table
alignleft, center or rightrefers to alignment of the table
valigntop, middle,bottomrefers to vertical alignment of the table
Above attributes can be better understood by following examples:

border Example

This will produce following result

Name Subject Marks
John History 79

bgcolor Example

This will produce following result

Name Subject Marks
John History 79

cellpadding Example

This will produce following result

Name Subject Marks
John History 79

cellspacing Example

This will produce following result

Name Subject Marks
John History 79

width Example

This will produce following result

Name Subject Marks
John History 79

align Example

This will produce following result

Name Subject Marks
John History 79

valign Example

This will produce following result

Name Subject Marks
John History 79