Tables and Hyperlinks
Tables and Hyperlinks
Hyperlinks in HTML
Royal Orchid
A leading name in the Hospitality Industry Hyperlinks
Tariff Plans
In this chapter. you will learn about creating tables and hyperlinks in HTML.
ibutes of
<TABLE Tag
f the other attributes of <TABLE> tag include bordercolor, bgcolor, background,
of t h e
other
Some
Soheight, cellspacingand cellpadding. Table
width, h e i g 5.1 on about
provides a brief description a
t h e s e a t t r i b u t e s ,
Table 5.1 Attributes of
<TABLE> tag
Attributes Description Example
border
This attribute specifies the thickness of the <TABLE border="3">
border around the table. The value is
in pixels.
specified
b o r d e r c o l o r
This attribute specifies the colour of the <TABLE
border of a table. bordercolor="blue"
This attribute specifies the <TABLE
bgcolor background colour
of a table. bgcolor="pink">
hackground This attribute specifies the URL of an image <TABLE
file to be displayed as the background of a background="C: \ r o s e s .
table. Jpg">
width=100%
width, These attributes specify the width and height <TABLE
height of a table. The value is specified in pixels or in height=200>
percentage.
This attr1bute specifies the space between two <TABLE cellspacing3
cellspacing
adjacent cells. The value is specified in pixels.
cellpadding This attribute specifies the space between the <TABLE cellpadding=3>
edge of a cell (cell wall) and the contents of the
cell. The value is specified in pixels.
The following HTML code uses different attributes of the <TABLE> tag to display the
output as shown in Fig. ).4.
CADriadmini DeP XCAUaedmar Dest
<TABLE border="3" bordercolor="blue" E [d ye Iportes Ioels Hep
bgcolor="yellow" width=50s
cellspacing=3 cellpadding=3> Cellpadding Country Capital
TR> <TH>Country</TH> <TH>Capital
Delhi
</TH> </TR> Cellspacing9 India
<TR> <TD>India</TD> <TD>Delhi </TD> </TR>
Gemany Berlin
KTR> <TD>Germany</TD> <TD>Berlin </TD> </TR>
</TABLE>
Fig 5.4 Output of a table using
cellspacing and cellpadding
attributes
67
CHECK YOUR PROGRESss
1. Global International Company wants to display
information in a tabular format on their website.
b0ok-relate
Design a
webpage that displays a table listing the names of the books
the names of the authors and the price list of five
books,
<TR bgcolor="lightblue">
<TH>Country</TH>
<TH>Capital</TH>
</TR>
<TR>
68
Lrolor="mistYrose">Delhi </TD>>
the
All the cells in
<TD b g c o l
T D
or="yel
b g c o l o r
llowgreen">Berlin
TR>
Couitry Capital
TABLE India Delhi
Germany Berlin
the Align
Attribute of the
Using
and
<TD> fags
TR>
5.6, the
contents of the header row are 5.5 Output of using bgcolor a table
In Fig.
Fig and cell level
by lefault. To change the attribute at the row
centrally aligned
a l i g n m e n i of the text in the other
hhorizontal
or
c a n m a k e use of the align attribute.
ows, you
bordercolor="blue" width=50%>
TABLE border="6"
<TR bgcolor=lightblue">>
Right alignment at
Center alignment
at the row level the data cell level
<TH>COuntryK/TH>
<TH>Capital</TH>
</TR>
</TABLE>
Quick Tip
To include an image or a list item inside a data cell, you can enclose the <IMG> tag or fthe
OL tag inside the <TD> or the <TH> tag.
rorexample: <TD><IMG src ="£lowers.jPg"></TD>
69
Using the
Rowspan and
You can make use of the Colspan
Attributes of the <TD>
rowspan and colspan Tag
merge the data cells (Fig attributes when there is a
or
row-wise. The HTML codes5.7 and
Fig. 5.8). The data cells can be
need to
merged
rowspan and colspan column-w
in Table 5.3 the
the <TD> tag. use
attributes e
Table 5 3 HTML code using the
rowspan and colspan attributes
Using the Rowspan Attribute
<TABLE border-2 cellpadding-4> Using the Colspan Attribute
<CAPTION> <TABLE border-2 cellpadding=4>
Region Wise Sales Report <CAPTION>
/CAPTION> Region Wise Sales
Report
KTR> </CAPTION>
<TR>
<TH>Region</TH> <TH Colspan=2
<TH>States</TH>
<TH>Units Sold</TH>>
K/TR>
bgcolor="#99CCFF">North</TH> </TR>
<TR>
<TR> <TD>Jammu arnd Kashmir</TD>
<TH rowspan=2 <TD>1493</TD>
</TR>
bgcolor="#99cCFF">North</TH>
<TD>Jammu and Kashmir</TD> <TR>
<TD>1493</TD <TD>Haryana</TD>
<TD>Karnataka</TD>
</TR> <TD>3829</TD>
<TR> </TR>
<TD>Haryana</TD> <TR>
<TD>3829</TD> <TD>Uttar Pradesh</TD>
</TR <TD>0283</TD>
<TR>
</TR>
<TH rowspan2 <TR>
<TH colspan=2
bgcolor="#99cCFF">South</TH>
<TD>Kerala</TD> bgcolor="#99cCFF">South</TH> </TR>
<TD>4827</TD> <TR>
</TR>
<TD>Kerala</TD>
<TR <TD>4827</TD>>
<TD>Tamil Nadu</TD> </TR>
<TD>7246</TD> <TR>
</TR <TD>Tamil Nadu</TD>
</TABILE> <TD>7246</TD>
</TR
<TR>
<TD>5689</TD>
</TR
</TABLE>
70
DAerri Dr P CX cAUertadnsDesn CAUer edmDe P-CxCAVeradririDeskt
Ed ew Favorites oos Heip Frvortes Iools Heldp
North
States Units Sold
Reglon Jammu and Kashnir 1493
Jammu and Kashmir 1493 3829
Haryana
North
Haryana 3829 Utar Pradesh 0283
Fig 57 Output (using the rowspan attribute) Fig 5.8 Output (using the colspan attribute)
QUICK QUESTION
1. State whether the following statements are True or False.
71
CREATING HYPERLINKS IN HTML
While surfing the Internet, you come across several text
strings or images which wh
clicked, open a different webpage. These text
strings images
or are called
hyperlinks
when
Hyperlinks interconnect the webpages over the World Wide Web.
Attribute Description
href This attribute indicates the destination of the link.
External Linking
The external linking involves connecting two different webpages. When click
a
hyperlink, a new webpage to which the hyperlink is linked gets displayedyouin the
browser window. You can link pages within the same
over the Internet. Table 5.5 illustrates
directory or to any other page
some of the
examples of external linking.
Table 5.5 Examples of external linking
Linking pages within the same directory Linking pages to the
first.html links to.> second.html
pages over
Internet
first.html links. to.> Google Web Page
HTML source code in first.html
HTML source code in first.html
<A href="second.html"> Click to A href="http://www.google.com
open Second file</A>
Click here to visit Google Web
Page</A>
72
following H T HTML code illustrates the of first.html to lnk to
wing use <A> tag in the file
he
i f t e r e n t w e b p a g e s .
HTML
A href=",
second.html"> Click to open Second file </A><BR><BR>
A href=")
http:\\www.google. com"> click here to visit Google Web
Page </A>
HTML
output
of the above HT code is shown in Fig. 5.9.
The
Cenadnbe
Che to open
9 CX
Sacond tile
CAUsers ad
cAUsersladmin\ Deskt
YouTube S Google
Internal Linking
the same webpage. This type of
Internal linking involves linking various sections of
It lets the u s e r view the desired section
linking is useful when a webpage is very long.
bookmark to go to a particular segment
of a page quickly. Internal linking s e r v e s a s a
to the information he/she is looking
of the webpage. This helps the u s e r to quickly jump
is a n example of internal
for. For example, Go to top of the page link in webpages
linking (Fig. 5.10).
Internal linking is a two-step process.
Use the attribute of the <A> tag to give a name to the section that has to be
name
linked to.
Dxample: <a name="xyz"> You will be linked here</A>
2 Use the href attribute of the <A> tag to refer to the named section preceded by
the # symbol.
AAmple: <a href=" #xyz"> You w i l be taken to the linked section</A>
73
The following HTML code demonstrates the use of name and href attributes of
<a
tag to lik the text 'Go to top of the page' to the top of the page. A>
<A name=" top"><H1>Introduction</H1></A>
<FONT face=comic sans ms" size="5"
Multimedia is any combination of
text, graphic art, sound, animation ciUserladminlDe P-CxSCAUsersadma
Ete Fdit yiew Favorites Jools telp Deiz.x
and video delivered to the user
it improves information retention.
by means of a computer or other This makes multimedia a very effective
communication tool in a variety ofarcas such
electronic media. An effective as
in business as a presentation and sales tool, in
multimedia presentation not only home for entertainment and games, in education
forteaching and training, in public places for
presents information in a dazzling
information and advertising, etc.
and entertaining manner, but is also
more effective in holding attention
and interest of the viewer and it
lmproves information retention. Go to top ofthepage
<BR>This makes multimedia a very
etfective communication tool in a
Fig 5.10 Page with an internal link
variety of areas such as in business
as a presentation and sales tool, in
home for entertainment and games,
education for teaching and training,
in
Quick Tip
in public places for information and The title attribute of the <A> taq
can be used for displaying a
advertising, etc. tooltip
that pops up when the mouse is
/font> moved over a hyperlink.
BR><BR><BR><BR><BR>
<A href="#top"> Go to top of the page
</A>
Email Linking (Linking to an Email Address)
To link text to an email address, you use the mailto: keyword before the email addres
in the href attribute of the <A> tag. For example, to link the text 'Send an
email address mariajoseph@ gmail.com, you can write the
Email to th
following HTMIL. code
<A href="mailto: maria_joseph@ gmail.com">Send an Email</A>
Quick Tip
You may use the link attribute of <BODY> tag to specify a different colour for the links in a
webpage. Also, you can use the vlink attribute of the <BODY> tag to specify a colour for the visited
links.
74
CHECK YOUR PROGRESSs
QUICK QUESTION
Recap Time
Tables are defined using the <TABLE> tag in an HTML document.
is divided into rows using the <TR> tag and each row is divided into
A table
data cells using the <TD> ta
E A table heading can be inserted using the <CAPTION> tag.
B The attributes of the <TABLE> tag include border, bordercolor, background, width,
height, cellspacing, and cellpadding.
The attributes of <TR>, <TD>, and <TH> tags include align, bgcolor, rowspan and
colspan.
are the text strings or the images in a webpage which when clicked,
link
Hyperlinks
to a different webpage or another section of the same webpage.
T h e <A> tag can be used to create hyperlinks in a webpage.
The three types of linking in HTML are external, internal and email.
The two important attributes of <A> tag are href and name.
75
ANSWERs TO QUICK QUESTIONS
1. (a) True (b) False (c) True (d) True (e) False
2. (a) name (b) mailto: (c) href
Assessment Time
Choose the correct answer.
(a) Which of the
following is not an attribute of the <TABLE> tag?
(i) border (ii) bgcolor
(ii) background
(b)
rowspan
Which one of the following attributes of the
two adjacent cells?
<TABLE tag specifies the space
betwes
een
i) colspan i) cellpadding
i) cellspacing (iv) border
(c) Which of the following tags is used to add columns to a table?
i) <colspan <TD
ii) <TR (iv)<A>
d) Which of the following is the correct code for creating a
hyperlink?
(1) r.ame=http://www.google.co.in> Google Home Page</A>
(11) url=http://www.google.co.in> Google Home Page</A>
) href=http://www.google.co.in> Google Home Page</A>
(iv) http://www.google.co.in</A>
2 Fill in the blanks using the words given in the box.
TR Hyperlink Table <CAPTION> href name
(a) A grid ofrows and columns is known as a le
b) The T R ) tag is used to add rows to the table.
(c) The tag usedfor inserting a table heading is AP TION
(d) A HyPJKeonneete
connectseone webpage to another.
(e) and OMA are the two attributes of the
tag
8Write the HTML commands for the following.
(a) To create a table with four pixels thick border of blue colour
(b) To create a table with background colour as yellow
(C) To set the background colour of a row as yellow
(d) To centre align the contents of a cell
(e) To set the image flower.jpg as a hyperlink to the file "Garden.html
76
A n s w e e r the following questions.
(a)
(:)
Which tags are Used to define the basic structure of a table in H'TM?
() Ditferentiate between cellspacing and cellpadding attributesof TABLE tag.
(c)
Give the use of Anchor (A>) tag.
Ditferentiate between internal linking and external linking.
()
How is internal linking done in a webpage?
Explain with the help of an example how to link any text to an email address
(
Activity Time
You are the activity incharge of your school.
Summerville Heritage School
You have been assigned the responsibility of
Activities being conducted during summer vacations
Fwtonsol rtrient
balanced diet. She wants you to Reguate Body funcT
Carbelydntes tens etcihe
Preteins Lpeds
design a webpage that brings out Lpide (Fats end oile) Vitenins
Minerel Mneruls
Water Wutar
the importance of various nutrients cl M foleg to more tormas
.Carbobydote
in our diet and their functions.
oteins
alongside.
Link the list items to the following pages.
Carbohydrates to carbo.html Fats to fats.html
Proteins to pro.html Vitamins to vit.html
Minerals to mi.html
77