|
Tables are used extensively on
many web sites to bring structure to a page. There
are small tables and big tables- small ones are
often used simply to encompass and organize a
section of the page, such as a spreadsheet data.
Large ones are used to build a structure to the
entire document. An HTML table may look something
like this:
Tables are built from 3 basic &
must-use tags:
| <table></table> |
Defines a
table |
| <tr></tr> |
Defines a row
within the table |
| <td></td> |
Defines a cell
within the
table |
●
Creating a table:
To
define a new table, we must begin the code with
<table> tag. After that, we will define the
number of rows in the table using <td> and
number of cells using <tr> tag.
This
is an example of a two cells table:
<table> <tr> <td>Cell
1</td> <td>Cell
2</td> </tr> </table>
It
will look like that:
Now
let's create a table with two cells and two
rows:
<table> <tr> <td>Cell
1</td> <td>Cell
2</td> <tr> <td>Cell
3</td> <td>Cell
4</td> </tr> </table>
It will
look like that:
| Cell1 |
Cell2 |
| Cell 3 |
Cell
4 |
▪ Since we want two rows, there are two
<tr> tags present. Since we want to cells in
each of the rows, there are two <td> tags
present in each <tr>.
● Table Attributes:
The table tag has various attributes
and option that you may want to set after you have
created the tables.
| border= |
Defines the border width
in pixels |
| width= |
Defines the
width of the table or cell in pixels or
%. |
| height= |
Defines the
height of the. table or cell in pixels or
% |
| cell
spacing= |
Defines
the spacing between each cells in
pixels. |
| cell
padding= |
Defines
the distant between the cell and the content
inside. |
|