Breaking News

Attributes

Attributes
 
Tags Attribute Value Description
<table> align left,center,right Aligns the table. Deprecated. Use styles instead.
bgcolor rgb(x,x,x),#xxxxxx, colorname Specifies the background color of the table. Deprecated. Use styles instead.
border pixels (0-n) Specifies the border width. Tip: Set border=”0″ to display tables with no borders!
cellpadding pixels, % Specifies the space between the cell walls and contents
cellspacing pixels, % Specifies the space between cells
width pixels, % Specifies the width of the table
 
 
Align
This attribute can have the value center, left, right. By using this table can be aligned on the page.
 
bgcolor
bgcolor is used to give the background color to the table. It can have the values in the three type, rgb (x,x,x) combination, #xxxxxx (color code), or color name.
 
border
border attribute of the table is used to provide the border style to the table. Its value is given in pixels (0-n). Above table has border=”5″.
if you want your table should not have border then define border=”0″.
 
width
It specifies the width of the table. Its value is also given in pixels (0-n) or %.
 
cellpadding
It specifies the space between the cell walls and contents. Its value is also given in pixels (0-n) or %.
 
cellspacing
It specifies the space between the cells. Its value is also given in pixels (0-n) or %.
 
 
<th> <tr> and <td>Tag
 
<th> tag
Defines a table header cell in a table. The text within the th element usually renders in bold.
 
Format:
<th> this is the header </th>
 
 
<tr> tag
<tr> tag defines a row in a table.
 
Format:
<tr> <td>table data </td> </tr>
 
 
<td> tag
<td> tag defines the table data. This tag is used inside the <tr> tag.
 
Format:
<td> table data </td>
 
The next table defines the different attributes that can be used by <th>,<tr> and <td> tags.
 
Tags Attribute Value Description
<th>,<td>,<tr> align left,center,right Specifies the horizontal alignment.
<th>,<td>,<tr> bgcolor rgb(x,x,x),#xxxxxx,
colorname
Specifies the background color of the table. Deprecated. Use styles instead.
<th>,<td> colspan number Indicates the number of columns this cell should span
<th>,<td> rowspan number Indicates the number of rows this cell should span
<th>,<td>,<tr> height pixels Specifies the height of the table cell. Deprecated. Use styles instead.
<th>,<td>,<tr> Valign top,middle,bottom,
baseline
Specifies the vertical alignment of cell content
<th>,<td> width pixels % Specifies the width of the table cell. Deprecated. Use styles instead.
 
 
<caption> Tag
<caption> tag defines a table caption.
 
Format:
<caption>This is a caption</caption>
 
 

<thead>,<tbody> and <tfoot> tag

 
The thead, tfoot and tbody elements enables you to group rows in a table. When you create a table, you might want to have a header row, some rows with data, and a row with totals at bottom. This division enables browsers to support scrolling of table bodies independently of the table header and footer. When long tables are printed, the table header and footer information may be repeated on each page that contains table data.
 
Example for <thead>,<tbody>and <tfoot>
 
Example Output
<table border = “1”>
<thead>
<tr>
<td>This text is in the THEAD</td>
</tr>
</thead>
<tfoot>
<tr>
<td>This text is in the TFOOT</td>
</tr>
</tfoot>
<tbody>
<tr>
<td> This text is in the TBODY</td>
</tr>
</tbody>
</table>
This text is in the THEAD
This text is in the TFOOT
This text is in the TBODY
 
 
Attributes of <thead>,<tbody> and <tfoot>
 
Attribute Value Description>
align right,left,center,justify
char
Defines the text alignment in cells.
Valign top,middle,bottom,baseline Specifies the vertical text alignment in cells.
 
so now lets do some Practical.
Just write/copy this example on any text editor new file and save the file and open in the browser and see how it looks.

Check Also

Table Tags

Table Tags   Tag Description <table> Defines a table <th> Defines a table header <tr> …