Chapter 5 Tables PR
Chapter 5 Tables PR
Contents
• THE TABLE TAG
• ATTRIBUTES OF <TABLE> TAG
• CELLSPACING
• SPANNING ROWS AND COLUMNS
Tables allow information to be in rows and columns.
They are used as a way of presenting data in a highly
controlled tabulated form giving greater control over
positioning of elements.
Apart for allowing text to be arranged in columns tables can
be used:
1. To divide the page into various sections
2. To create menus
3. To add interactive form fields
4. To create fast loading headers of page
5. For easy alignment of images
<TABLE> tag
• The <TABLE>…. </TABLE> tag is used to signify the start of a
table definition.
• The element has four sub-elements; Table Row <TR> .. </TR>,
Table Header <TH> .. </TH>, Table Data <TD> .. </TD> and
Caption <CAPTION> .. </CAPTION>
• By default, table headings are bold and centered.
• This gives the caption for the title of the table. The
default position of the title is centered at the top of the
table.
• It is only permitted after the TABLE tag.
• Caption tag has the following align attribute values:
ALIGN=BOTTOM, TOP, LEFT, RIGHT
ATTRIBUTES OF <TABLE> TAG
• WIDTH
• Allows designers to set the width of the table using two methods,
either as an explicit value or a percentage value. Using the first
method it is possible to create a table to exact horizontal dimensions.
• e.g.
• <TABLE WIDTH=500> gives the table which is fixed to 500 pixels.
• The second method, whilst not as exact, uses a percentage of the
available space which allows the table to expand or contract along
with the browser if it is resized at any point.
• e.g.
• <TABLE WIDTH="90%"> forces the table to take 90% of the
available horizontal space.
• HEIGHT
• It is declared just like the width attribute, however, not all browsers
accept this attribute.
BORDER
• This attribute sets the thickness of the borders surrounding the table.
• e.g. <TABLE BORDER =2>
• If no border is desired a value of 0 BORDER=0 is given.
• Every table is a collection of rows and cells. Each row contains a number of
cells, each of which contains the table information.
• Rows must be set up before cells can be added in. In order, to create a table
row the <TR> and </TR> container is used. Each row can contain a number
of cells.
• The color of the border can be set by declaring:
• <TABLE BORDERCOLOR = red>
• A border can also be set using the CSS border property:
• Example
• table, th, td {
border: 1px solid black;
}
TABLE ROWS