Tables


About HTML      Colors      Images and Links       Tables     Lists      Index Page

HOW TO MAKE A TABLE

  1. Start and end with a table tag. <table></table>
  2. <tr></tr>makes a row, everything in between the tr tag is one row
  3. Each cell is coded for by a <td> and a </td> (stands for table data). You make the row and then specify the amount of cells in each row.
  4. Within in the table tag, there is the border attribute. This creates the characteristic table lines.
  5. <table border="60">
  6. Another table attribute is the width attribute. This creates more horizontal space in each table cell. You can designate width in percents or pixels.
  7. Cell padding is also an attribute. <table cellpadding="20"> It creates space around the content in the cell
  8. Cell spacing puts space around each cell. The attribute is <table cellspacing="15">

Examples:
A plain table:
12
34
56

A table with border:
12
34
56

A table with border and width:
12
34
56

A table with border, width, and cellpadding.
12
34
56

A table with border, width, cellpadding, and cellspacing tags:
12
34
56

The code for this table looks like:
<table border="1" width="60" cellpadding="20" cellspacing="15">
<tr><td>1</td><td>2</td></tr>
<tr><td>3</td><td>4</td></tr>
<tr><td>5</td><td>6</td></tr>
</table>

More Attributes

The bg color attribute can be put within table tag. The bg color attribute changes the color of the entire table when place within the table tag. It can be placed in the row tag or in a singular cell. Examples are below.
In this table, the bgcolor tag is in the table tag.
AB
CD
EF


In this table, a whole row is white.
AB
CD
EF

In this table, one cell is white because the bgcolor attribute was placed within the cell tag <td>
AB
CD
EF

When the bgcolor attribute is placed in the table tag and another bgcolor attribute is placed in a cell or row, the bgcolor attribute within the cell or row won't be overridden because they are more specific than the bgcolor in the table.
AB
CD
EF

Merging Cells Horizontally and Vertically

You can't just delete cells. In order to merge cells there are two attributes: rowspan and colspan. When you want to create one cell in a particular row, use the colspan attribute. When you want to create one long vertical cell, use the rowspan attribute. Both attributes are placed within the cell tag <td colspan="3">

This table is an example of the colspan attribute because the cell spans three cells.
1
343
566
This table is an example of the rowspan attribute because the cell spans three cells. When using the rowspan attribute, row one (with the rowspan attribute) has one extra cell.
113
34
56

Background Images

To add a picture into the background of a table, use the background attribute. <table background="image.extension"> This attribute can also be applied to rows and cells as well.
179
343
566


Now a fun table!
My Colleges
AcceptancesGeorgetownWash USanta ClaraBoston CollegeTCU
Waiting to Hear FromBrownNorthwesternBoston University

Page Created By: Alice
March 24, 2010