Tables in HTML
Tables are used as page layouts to help better control the placement of things on your web page. Tables play an important role in HTML. Table is a combinition of column and rows.
<TABLE> tag
The <TABLE>… </TABLE> tag is the main tag used to create a table, table tag has following attributes.
| bgcolor | bgcolor is used for chage background color of table | <table bgcolor="red"> |
| width | width is used for specify width of table | <table width="300"> or <table width="30%"> |
| height | height is used for specify height of table | <table height="300"> or <table height="30%"> |
| border | border is used to increase border of table in numeric, 0 specifies no border |
<table border="1"> |
| bordercolor | is used for chage background color of table | <table bordercolor="blue"> |
| Align | is used for change table alignment | <table align="center"> |
| cellpadding | is used to increase dinstance between the cells | <table cellpadding="1"> |
| cellspacing | is used to increase white space between the cells | <table cellspacing="0"> |
Example
<TABLE border="1" bgcolor="red" cellpadding="1" cellspacing="1" >........</TABLE>
<TR> Tag
<TR> stands for table row,the <TR></TR> tags is used to define a horizontal row. Each row may be further divided into cell.
| bgcolor | bgcolor is used for chage background color of Rows | <tr bgcolor="red"> |
| width | width is used for chanege width of rows | <tr width="300"> or <table width="30%"> |
| height | height is used for change height of rows | <tr height="300"> or <table height="30%"> |
| Align | is used for change Horizontal alignment of rows | <tr align="center"> |
| Rowspan | is used for merge more than one row | <tr rowspan="2"> |
Example
<TABLE>
<TR align="center" bgcolor="blue">
</TR>
</TABLE>
<TD> Tag
<TD> stands for Table Data. The <TD></TD> tag is used to define cells (or columns) in a row. The <TD> tags always appear within <TR> tags always appear within <TR> tags.Each <TR></TR> tag has multiple cells, for example
<TABLE>
<TR>
<TD>Apples</TD>
<TD>Apples</TD>
</TR>
</TABLE>
| bgcolor | bgcolor is used for chage background color of Rows | <td bgcolor="red"> |
| width | width is used for chanege width of Cell | <td width="300"> or <table width="30%"> |
| height | height is used for change height of Cell | <td height="300"> or <table height="30%"> |
| Align | is used for change Horizontal alignment of Cell | <td align="center"> |
| Rowspan | is used for merge more than one cell | <td colspan="3"> |
<TABLE>
<TR>
<TD>Apples</TD>
<TD>Apples</TD>
<TD>Apples</TD>
</TR>
<TR>
<TD>Apples</TD>
<TD>Apples</TD>
<TD>Apples</TD>
</TR>
</TABLE>
Above table has two rows and each rows have 3 columns.
