Professional Documents
Culture Documents
TABLES
TABLES
WITH TABLES
When we need to represent data in form of rows and columns we use a container tag called <table>.
Each row is divided into one or more cells/ columns which can either be a
HEADER CELL or a DATA CELL.
001 ABC
HEADER
CELL
DATA
002 XYZ CELL
<TABLE>….</TABLE>
<Table> tag is part of body tag only.
It is not necessary that <table> tag is first tag in body.
The caption can appear either at top or at bottom of the table created. This can be done by using
ALIGN attribute of <caption tag>.
It is used immediately after opening <table> and before adding any table row
EXAMPLE
ALIGN ATTRIBUTE OF <CAPTION>
ATTRIBUTES OF TABELS
1. BORDER ATTRIBUTE
This attribute draws an inside and an outside border of the table.
When value of border is more than 1 then only the outside border changes but the inside always
remains 1.
Not adding border attribute will not add boundary to the table.
EXAMPLE
EXAMPLE – NO BORDER
2. ALIGN ATTRIBUTE- RIGHT, LEFT, CENTER
OUTPUT
3. WIDTH ATTRIBUTE
If width= 100% it means that it spans across entire browser window.
Width attribute is used with border, if we omit this attribute the width of the table is set according
to characters inside the cells.
EXAMPLE
4. HEIGHT ATTRIBUTE
5. BORDERCOLOR ATTRIBUTE
BORDERCOLOR attribute could be used to add border color to the table border
The output of table border color have different way of rendering in different browsers like Netscape
Navigator and MS Internet Explorer.
EXAMPLE
OUTPUT
OUTPUT OF GOOGLE
CHROME
OUTPUT OF INTERNET EXPLORER
6. TABLE BORDER- LIGHT and DARK ATTRIBUTE
Visual web browsers such as Netscape Navigator & Internet Explorer render table borders with 3D
appearance.
Mozilla Firefox shows light grey and dark grey in TOPLEFT and BOTTOMRIGHT.
EXAMPLE
OUTPUT
EXAMPLE
OUTPUT- MOZILLA FIREFOX
7. TABLE BACKGROUND COLOR
It helps in setting background color of the table.
EXAMPLE
8. <FONT> TAG WITH TABLE
Output in Internet Explorer
It does not affects the function of <TH> and <TD>. It only creates
‘n’ pixel between the cell and boundaries(top, left, right, bottom
cell boundaries)- IT IS NOT AFFECTED BY NUMBER OF
CHARACTERS
OUTPUT
CELLPADDING NOT AFFECTED BY NUMBER OF
CHARACTERS
OUTPUT
CELLSPACING
Cellspacing attribute indicates how many pixels of white
space in pixels should be there between individual cells.
Spacing of cells.
MergeCELLS
ROWSPAN
When the tables cell span across more than one row, it is
called ROWSPAN.