Pages

Create a Table in HTML

Table is collection row and columns.it display the data in set of row and columns .Tables allow you to arrange items in a grid pattern .The tags used to define tables in HTML are discussed in this section


The <TABLE> Tag is used to create a table
<TR>--This can used to create a table row .
<TD>--This can used to create a table cell
<TH>--This can used to create the heading of row and column
<CAPTION>-It define the caption for a table
The attributes of the <TABLE>tag used in the above Syntax
  • align--It Specifies the horizontal alignment of a table .
  • height--Specifies  the height of a table .The value for the height attribute can be specified either in terms of number of pixel 
  • width--Specifies the width of the table .The value for the width attribute can Specified either in terms of number of pixels .
  • border--Specifies the thickness of a table borders in pixels.
  • cellpadding--Specifies the space between the border and the content of the cell in pixels 
  • cellspacing--Specifies the space between two cells of a table in pixels .
  • bgcolor--Specifies the background color of a table
  • cols--Specifies the number of columns that a table contains.
  • hspace--Specifies the space between the left and right edges of a table .
  • vspace--Specifies the space between the top and bottom edges of a table.
 Program of Table Tag

<html>
<head>
<title>Create a Table in Html</title>
</head>
<body bgcolor="silver" >
<table border=1 align="center" width=600 cellspacing=5 cellpadding =1 cols=2>
<tr>
<th colspan=2 align="center" >Heading Text</th>
</tr>
<tr>
<td>one</td>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
<tr>
<td>Five</td>
<td>Six</td>
<caption align="bottom" >Table caption</caption>
</table>
</body>
</html>

The Table <caption> tag aligns the caption text of the bottom of the table .Save the file with any name such as table.html.

Output


0 comments: