Web Design
Web Design
Lesso n 4 on HTM L
lnserting Tables
ln HTML, creating a table is quite a complex process. The structure of creating a HTML table is as follows,
table bord€f tt For simple representation of the HTML code and the final
< =" f. >
output, the table is shown with different background colour.
< tr> There should not be any background colour based on the given
<td>sA< / Ed> code however.
</trr>
<tr>
<td>Woo Chung Yan< /Ed>
5A
Table row
< tr> t To make a table row there must be <tr> (See the above demo)
< / tr> tags.
Table cell
<td> t The <td> enables you to enter content into (See the above demo)
the cell.
lf you want to table header (first row of the table)
<th> to be in bold and/or with special features, you can Nil
use <th> instead of <td>.
Supplementary lnformation for <table> attributes:
HTML Tag Description
<tab1e width = 10 Opx" > rt
To specify that the width of the table is exactly
<tabIe width = tt10Oeo") 1,00 pixels or LOO% (full screen width).
< / t-r>
< tr>
<td>Erie< /Ed> ,Fil'srrlatlre
.
rlastnanre Ag*
< td>Tsang< / t-d> lr'*s-lto
<td>Lo< /Ed> iracky- lTong i:o
</tr>
<tr>
<td>ilacky< / td>
<td>Tong < / trd>
<td>20< / Ed>
</Er>
< / tabre>
\'
< td>Tsang< / Ed>
- LO}%
<td>L0 < / r-d>
</trr>
< tr height= rr f.0% "
<td>'Jaeky< / t,d>
<td>Tong< /trd>
<td>20< / t-d>
\ Eric Tsang tt)
</trr>
< / tabre> \ Jaeky Tong :0
HTML Tag Description
<tab1e border = 1!r >
rr
To specify the width of the border of the table.
<table align = r'Ief t I eenter I rightr! > To align the whole table (or a particular row or
<tr align = rtleft I eenter I rightrr > cell) on the left, c€nter or right.
<t,d align = rrlef t I center I right t' >
<table bgcolor = 'rgdtr > To define the background color of the table (or a
<table bgcolor = " #xxxxxxtr > particular row or cell), either a colour keyword
<table baekground = tt IMG 9222 .,JPGtt > To define the background of the table (or a
<table bordercolor = t'#xxxxxx '! > colour keyword (e.g. black, red, green etc) or a 6-
Lastnarne
(20 px)
<table cellpadding = rr lpxtr > To specify the margin (trrfl) between the text and
<table eellpadding = rt 2 0pxrt > the cell.
t
L*tr*r*f"*
Eric lTsang
iTsang ii t 0
J*clry l*- (1 px)
m
1+rirtb-"*-l Lasrname Age
rt
Eric
Ja*iry
EFTor:g i0
(20 px)
rowspan To span (merge) cells from multiple rows together.
"l*:il:!7:l5 Tsang
i''^:'
</Er>
<tr>
<td rowsp?fr= it2tr >Eri c</ td>
<td>Gu< / td>
<td>L7</trd> The text "Eric"
</Er> will span
<t,r> (occupy) two
<td>Tsang< / trd>
rows. Therefore,
<td> 20< / Ed>
only 2 horizontal
</Er>
cells (lastname &
< / table>
age) are needed
Classwork of Today:
H e ader