Tables

Tables

The <TABLE> tag starts a table element. The <TR> element starts a table row and the <TD> element starts a table cell within a row. Within each of these elements are a variety of attributes you can assign values to which you'll see below. All table tags must be closed with a matching </> tag.

CODE:

<TABLE>
  <TR>
    <TD><B>Holiday</B></TD>
    <TD><B>Month</B></TD>
    <TD><B>Day</B></TD>
    <TD><B>Icon</B></TD>
  </TR>
  <TR>
    <TD>Christmas</TD>
    <TD>December</TD>
    <TD>25</TD>
    <TD>Santa Clause</TD>
  </TR>
  <TR>
    <TD>Halloween</TD>
    <TD>October</TD>
    <TD>31</TD>
    <TD>Witch</TD>
  </TR>
</TABLE>

Border, Cellpadding, Cellspacing

Within the opening <TABLE> tag, you can add a variety of attributes to determine how the table will look. You can specify the width of a table (in pixels), add a border, add bacgkround color to the table, change the spacing between cells (cellspacing) or change the cellpadding around the data within cells (the space between the contents of cell and cell "walls").

Border:

The border attribute specifies if a border should be displayed around the table and cells.

Accepted Values:
Pixel value or percentage value (as a percentage of the width of a visitor's browser)

Code:
<TABLE border="3"> OR
<TABLE border="90%">

Cellpadding:

Use the cellpadding attribute to create some space around the contents of table cells (in th and td elements). 

Accepted Values:
Pixel value (by default cellpadding is set to 2 if you do not use this attribute in your opening table tag)

Code:
<TABLE cellpadding="10">

Cellspacing:

The cellspacing attribute is used to create space around (that is, outside of) table cells. Think of table cells as bricks, and the cellspacing as the mortar in between. You can change the thickness of that mortar by altering the cellspacing value

Accepted Values:
Pixel value (by default cellspacing is set to 2 if you do not use this attribute in your opening table tag)

Code:
<TABLE cellspacing="5">

No comments:

Post a Comment