Monday 27 May 2013

Tables in HTML

Table's are used to write data in tabular forms.

Each table has Rows <tr></tr> and inside each rows, we have table data <td></td>.
For Example
<table border="1">
           <tr>
                 <td>S No</td>
                 <td>Name</td>
          </tr>
          <tr>
                <td>1</td>
                <td>abc</td>
          </tr>
          <tr>
               <td>2</td>
               <td>xyz</td>
          </tr>
</table>
                       will look like
S No Name
1 abc
2 xyz




Some more attributes in tables;
We can also use <th> in first tr instead of td. <th> means table heading.
Text inside th will be bold and center align.
In td, it is normal and left align.

For Exp
S No Name
1 abc
2 xyz

A table has cellpadding and cellspacing.

CELLSPACING: Cellspacing is spacing between any two cells in a table.

For Exp,
Table with no cellspacing
S No Name
1 abc
2 xyz
Table with cellpspacing 0px
S No Name
1 abc
2 xyz
Table with cellpspacing 10px
S No Name
1 abc
2 xyz

CELPADDING: Cellpadding means padding of text from the cell.

For Exp
Table with no cellpadding
S No Name
1 abc
2 xyz
Table with cellpadding 0px
S No Name
1 abc
2 xyz
Table with cellpadding 10px
S No Name
1 abc
2 xyz


No comments: