Programming and Development Tools                              Web Programming




                                                                UNIT


                                                               2.6
Web Programming
Link




  OBJECTIVES
 This unit helps you to link various Web pages of a Web site using
 Hyperlinks.
 At the end of this unit, you will be able to
            Identify a link in a Web page.
            Differentiate Internal and External Hyperlinks.
            Open a Web page in a new Window.
            Change the colour of different states of a link.




Benchmark standard
          Organize the Web site by creating links between the Web pages of
          a Web site successfully.




Link                                                                    2.6-1
Programming and Development Tools                              Web Programming




Let us Revise!

 1. Name the different types of list.
 2. Name the tags used to create Ordered List.
 3. Name the attributes of <UL> tag.
 4. State how you will create Definition List.




 Introduction
 A good Web page is one which enables the user locate the information easily.
 Having all the contents in a single Web page is difficult. So, the content is
 distributed logically in different Web pages and linked to one another. Also, if
 a Web page is very long it will be difficult for the user to scroll the Web page
 to his desired location. These difficulties can be overcome by using
 Hyperlinks.


 2.6.1 Hyperlink
 A Hyperlink is a text or image that is linked to a location in the same Web
 page or to a different Web page. You can navigate through the Web pages
 easily by clicking the Hyperlinks.

        Hands-On!

 The following example illustrates the use of the Hyperlink.
 Open the HTML file Puzzle.html in Internet Explorer.
 The code in Puzzle.html file is given below:
 <HTML>
 <HEAD>
 <TITLE> Link </TITLE>
 </HEAD>
 <BODY>
 <H1 Align=”Center”> Winners are                    Great      Thinkers     and
 Losers are Great Blinkers </H1>
 Solve the following puzzles and prove that you are a
 great thinker.
 <OL>
 <LI>Puzzles related to weight

 Link                                                                      2.6-2
Programming and Development Tools                    Web Programming


                                                    Internal Hyperlinks
<UL Type="disc">
<LI><A Href="#Tomatoes">8 Tomatoes </A>
<LI><A Href="#Coins">6 Coins </A>                   Internal Hyperlinks
</UL>
<LI>Puzzles related to Maths
<UL Type="disc">
<LI><A Href="#Green">Green coloured      cubes </A>
<LI><A Href="#Multi">Multiplication and      Addition </A>
</UL>
                                                Internal Hyperlinks
<LI>Puzzles related to logical thinking
<UL Type=disc>
<LI><A Href="#Triplet">Triplet Brothers </A>
<LI><A Href="#Brother">Who is       younger? </A>
<LI><A Href="#Share">Share it equally </A>
</UL>
</OL>
<H2> Puzzles related to weight </H2>
<A Name="Tomatoes">
<H3>8 Tomatoes</H3>
There are 8 identical tomatoes supplied to you. One of
the tomatoes is lighter than all the other tomatoes. You
are given a balance to weigh. Find the lightest tomato by
weighing it 2 times only.


<A Name="Coins">
<H3>6 Coins</H3>
You have 6 coins of which one is heavier. Weigh them 2
times using a common balance and pull the odd one out,


<A Name="Green">
<H2> Puzzles related to Maths </H2>
<H3>Green Cubes</H3>
Paint a cube of side 4 cm with Green colour. Cut the cube
into 64 one cm small cubes. <BR>
How many cubes have?
<OL>

Link                                                               2.6-3
Programming and Development Tools                   Web Programming


<LI>No red colour on any side,
<LI>One face red,
<LI>Two faces red.
<LI>Three faces red.
</OL>
<A Name="Multi">
<H3>Multiplication and Division</H3>
AB multiplied by C gives DE. DE added to FG gives HI.
A,B,C,...I are different digits from 1 to 9. Find
A,B,C,....I<BR>


<A Name="Triplet"><H3>Triplet Brothers</H3>
Three triplet brothers of names Roger, Robin and Robert
are sitting in a row. Roger speaks the truth, Robin
Speaks lie and Robert speaks both. A man went to them and
asked the person sitting left "Who is sitting in the
middle?” He answered "Roger". He asked the person sitting
in the middle "What is your name?” He answered "Robert".
He asked the person sitting in the right "Who is sitting
in the middle?” He answered "Robin". Find in which
position Roger, Robin and Robert are sitting?


<A Name="Brother">
<H3>Who is younger?</H3>
Sister says "I am older than my Brother". Brother says "I
am younger to my Sister". Atleast one of them must be
lying. Who is younger?


<A Name="Share">
<H3>Share it equally</H3>
Three brothers are given 4 jugs of capacities 5,11,13 and
24 litres. You have 24 litres of water in 24 litre jug.
Share the water equally so that each gets 8 litres of
water.
<BR><BR><A Href="Answers.html">Show Answers</A>
</BODY>                                          External Hyperlink
</HTML>
                             Code Sample 2.6.1


Link                                                             2.6-4
Programming and Development Tools                Web Programming


The code in Answers.html is given below:
<HTML>
<HEAD>
<TITLE> Answers </TITLE>
<BODY>
<H1 Align=Center> Answers to the puzzles </H1>
<H2> 8 Tomatoes </H2>
Take 3 Tomatoes in each pan. There are 2 possibilities.
<OL>
<LI>If there is no difference in weight, take the other 2
tomatoes and put one in each pan. The one with lesser
weight is the lightest of all.
<LI>If there is difference, remove the tomatoes from the
heavier side. Take the other 3 tomatoes and put 1 in each
pan and keep one outside. If there is no difference the
tomato that is kept outside is the lightest. If there is
difference the lightest tomato is easily identified from
the weighing.
</OL>
<H2> 6 Coins </H2>
Take 3 coins in each pan. Remove the coins from the
lighter side. Take the 3 coins from the heavier side and
put 1 in each pan and keep one outside. If there is no
difference the coin that is kept outside is the heaviest.
If there is difference the heaviest coin is easily
identified from the weighing.
<H2> Green Cubes </H2>
<OL>
<LI> No colour on any side - 8 cubes
<LI> Green colour on one side - 24 cubes
<LI> Green colour on two sides - 24 cubes
<LI> Green colour on three sides - 8 cubes
</OL>
<H2> Multiplication and Addition </H2>
A=1 &nbsp; B=7 &nbsp; C=4 &nbsp; D=6 &nbsp; E=8 &nbsp;
F=2 &nbsp; G=5 &nbsp; H=9 &nbsp; I=3
<H2> Triplet Brothers </H2>
Left=Robert &nbsp; Middle=Robin &nbsp;Right=Roger

Link                                                      2.6-5
Programming and Development Tools                          Web Programming


<H2> Who is younger? </H2>
Sister
<H2> Share it equally </H2>
The steps to be followed are: <BR>
<OL>
<LI> Pour water from 24 litre jug to 13 litre jug.
<LI> Pour water from 13 litre jug to 5 litre jug.
<LI> Pour water from 13 litre jug to 11 litre jug.
<LI> Pour water from 5 litre jug to 13 litre jug.
<LI> Pour water from 24 litre jug to 13 litre jug.
<LI> Pour water from 13 litre jug to 5 litre jug.
<LI> Pour water from 5 litre jug to 24 litre jug.
</OL>
</BODY>
</HTML>
                             Code Sample 2.6.2
The Web page shown in Figure 2.6.1 is displayed in the browser window.




Link                                                                 2.6-6
Programming and Development Tools                               Web Programming




                Figure 2.6.1: Web Page Showing Hyperlinks

In Figure 2.6.1, the coloured texts are Hyperlinks. There are two types of
Hyperlinks. They are:
       Internal Hyperlink and
       External Hyperlink.
Click 8 Tomatoes. This page scrolls up to display the 8 Tomatoes puzzle in the
same page. This Hyperlink is linked to the content in the same page. This
type of hyperlink is called Internal Hyperlink. Try solving all those puzzles. If
you cannot solve, scroll to the last line of the page. Click the hyperlink named
Answers. A new Web page opens, displaying the answers to the puzzles.
Here, the hyperlink Answers is linked to another Web page, which is
Answers.html. This type of hyperlink is called External Hyperlink.
Both Internal Hyperlink and External Hyperlink are created using <A> tag.
This tag is also called as Anchor tag.




Link                                                                       2.6-7
Programming and Development Tools                                          Web Programming



Internal Hyperlink
The Internal Hyperlink is a hyperlink that is linked to the content in the same
Web page. The content to which the hyperlink is linked is typed in the same
HTML document. Figure 2.6.2 explains
the working of Internal Hyperlinks.

In the Web page shown in Figure 2.6.1,
there are seven hyperlinks under three
sub-headings. When you click any of
those hyperlinks, say 8 Tomatoes, the
Web page scrolls to the 8 Tomatoes
puzzle because this hyperlink is linked to
the place where 8 Tomatoes puzzle is
explained. The text to be used as
hyperlink is placed between the <A> and
</A> tags.
The tag used to create 8 Tomatoes
hyperlink is
                                      Figure 2.6.2: Internal Hyperlink
            <A Href = “Tomatoes”> 8 Tomatoes </A>.
Here, HREF is the attribute that specifies to which place the document is
linked. The target text of the link is preceded by another <A> tag, The <A> tag
here should be used along with NAME attribute as
            <A Name=” Tomatoes”>.
The values given for Href and Name attributes should be the same.



        Lab Exercise

Lab Exercise 1: Open D6_1.html in Internet Explorer. The following code will be present in
                 D6_1.html.
<HTML>
<HEAD>
<TITLE> Menu Choices </TITLE>
<A Name="TOP">
        <H1 Align="CENTER"> Menu Choices </H1>
</HEAD>
<BODY >
<H1> <A Href="#MEAT"> Meat Dishes </A> <BR><BR>
                <A Href="#SEAFOOD"> Seafood Dishes </A><BR><BR>

Link                                                                                   2.6-8
Programming and Development Tools                  Web Programming


             <A Href="#VEG"> Vegatable Dishes </A><BR>
</H1>
        <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
        <H2 Id="MEAT"> Meat <BR> </H2>
             <UL>
                     <LI> Beaf <BR>
                     <LI> Chicken <BR>
                     <LI> Deer <BR>
                     <LI> Lamb <BR>
                     <LI> Turkey
             </UL>
<H6 Align=CENTER><A Href="#TOP">Back to Top
</A></H6>
        <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
        <H2 Id ="SEAFOOD"> Seafood </H2>
             <UL>
                     <LI> Crab <BR>
                     <LI> Cattle Fish <BR>
                     <LI> Fish<BR>
                     <LI> Oyster <BR>
                     <LI> Prawn <BR>
             </UL>
        <H6 Align=CENTER><A Href="#TOP">Back to Top</A></H6>
        <BR><BR><BR><BR><BR>
        <H2 Id ="VEG"> Vegetables </H2>
             <UL>
                     <LI> Brocolli <BR>
                     <LI> Carrot <BR>
                     <LI> Cabbage <BR>
                     <LI> Cauliflower <BR>


             <LI> Potato
             </UL>
<H6 Align=CENTER><A Href="#TOP">Back to Top
</A></H6>

Link                                                        2.6-9
Programming and Development Tools                                                Web Programming


</BODY>
</HTML>


   1. Identify the tag which is used to create link?
   2. Name the attribute which is used specify the document to which the hyperlink is linked
       to?
Lab Exercise 2: Open Malaysia.html that you have created under the folder in your name in
                 C:.
    1. When you click on the text “National Flower”, the following description should be
       displayed in the same page using internal hyper link.
                                            National Flower
        Bunga Raya (hibiscus) is the national flower in Malaysia. No one knows when it’s
        introduced to Malaysia. It is originated in Asia and the Pacific Islands. Hibiscuses are
        found in many difference colours and colour combinations. But Malaysian has chosen
        the red five-petalled types as their national flower. It is also used for medicine and
        cosmetics, for dyeing the hair and eyebrows. Some of them still use the roots of the
        flower as a cure for fever. The petal can be used for polishing shoes.
    2. When you click on the text “Fruits of Malaysia”, the following description should be
       displayed in the same page using internal hyper link.
                                      Fruits in Malaysia
                                              Durian
Durian is called the King of fruits. Durian is a big, green thorny fruit. The Malaysians love this
fruit even the foreigner like the taste. It is cultivated in all parts of Malaysia. The fruit can be
made into durian cake, durian powder and jam.
                                            Star Fruit
Another local fruit is star fruit. It has a greenish to yellowish colour. When you cut the fruit
across it, it will look like a star. The fruit can be made into jam, jelly and fresh juice.


External Hyperlink
The external Hyperlink is a hyperlink that is linked to another HTML
document. Figure 2.6.3 explains the working of External Hyperlinks.




Link                                                                                          2.6-10
Programming and Development Tools                                           Web Programming




                           Figure 2.6.3: External Hyperlink

In the Web page shown in Figure 2.6.1, the hyperlink Answers is linked to the
HTML document named Answers.html. When you click the Answers hyperlink,
the Answers.html document opens in the browser window.
The tag used to create Answers hyperlink is
             <A Href = “Answers.html”> Answers </A>
Here, Href is the attribute that specifies the document to which the hyperlink is
linked.

         Note

There is no difference in the appearance of Internal Hyperlink and External Hyperlink.

       Tip

It is possible to create links to any other Web site from your Web page.



        Lab Exercise

Lab Exercise 3: Open D6_2.html in Internet Explorer. The following code will be present in
D6_2.html.


Link                                                                                     2.6-11
Programming and Development Tools                                           Web Programming


<HTML>
<HEAD>
<TITLE> Hyper Link </TITLE>
        <H1 Align="CENTER"> Hyper Links </H1>
        <HR>
</HEAD>
<BODY Bgcolor="PINK" Text="#FF00FF" Link="#FF0000"
Vlink="#000080" Alink="#800080" >
<H3>
        <A Href="http:yahoo.com">Click here to go to
Yahoo</A><BR>
        <A Href="http:google.com">Click here to go to
Google</A><BR>
        <A Href="http:microsoft.com">Click here to go to
Microsoft</A><BR>
</H3>
</BODY>
</HTML>
   1. Identify the tag which is used to create link in source code D6_2.html.
   2. Underline the attribute which is used with the <A> tag to specify the name of the file to
      be linked to.
   3. Name the attribute which is used to sets the colour for active links, visited links and
      hyper links in source code D6_2.html.

Lab Exercise 4: Open D6_2.html in Internet Explorer.
   1.   View the source code in notepad.
   2.   Apply the active link colour to Maroon.
   3.   Apply the visited link colour to Yellow.
   4.   Apply the hyperlink colour to Green.
   5.   Save the file and view the output in the browser.

Lab Exercise 5: Open Malaysia.html that you have created under the folder in your name in
                 C:.
   1. When you click on the text “States of Malaysia”, the “States.html” which you have
      created under the folder in your name in C: should open in new window.
   2. When you click on the text “Festival”, the “Festivals.html” which you have created
      under the folder in your name in C: should open in new window.
   3. When you click on the text “Whether and Climate in Malaysia”, the “Climate.html”
      which you have created under the folder in your name in C: should open in next
      window.

Link                                                                                     2.6-12
Programming and Development Tools                                             Web Programming




        Self-Check Exercise 2.6.1

Correct the following wrong sentences:
    1. Images cannot be used as Hyperlinks.
    2. The External Hyperlink is a hyperlink that is linked to the content in the same Web
       page.
    3. In case of External Hyperlink, the content to which the hyperlink is linked is typed in the
       same HTML document.


Changing the Colour of the Link
The hyperlink is distinguished from ordinary text by the colour. There are
three states of a link. They are
            The link that has not been visited earlier,
            The link that is being visited and
            The link that had been already visited.
These states are identified by the colour of the link. The default colours of a
link in 3 different states are given in Table 2.6.1.
                    State of Link                  Default Colour of Link
                    Unvisited Link                          Blue
                   Link being visited                              Red
                       Visited Link                               Purple
                      Table 2.6.1: Default colours of a link
In Figure 2.6.1, the first link is purple in colour which means it is a visited link.
All the other links are blue in colour which means they are not visited so far.
The colour of the links can be changed using the attributes of the <BODY> tag.
The attributes used to change the colour of the links in different states are
given in Table 2.6.2.


                    State of Link                           Attribute
                    Unvisited Link                             Link
                   Link being visited                             Alink
                       Visited Link                               Vlink
   Table 2.6.2: Attributes of <BODY> tag to change the colour of a link

         Note
Alink stands for Active Link and Vlink stands for Visited Link.



Link                                                                                       2.6-13
Programming and Development Tools                                              Web Programming


For example, the following code displays the colour of active link in Green,
unvisited link in yellow and visited link in Magenta.
<BODY Link=”Yellow” Alink=”Green” Vlink=”Magenta”>
Anchor Tag and Target Attribute
The Target attribute can also be used within the anchor tag. This attribute
specifies where the linked document should be opened. To open the linked
document in a new window, the value to be assigned to the Target attribute is
_blank. For example, to open the Answers.html document in a new window the
code is
<A Href = “Answers.html” Target = “_blank”> Answers </A>.

          Note
In the absence of Target attribute, the Web pages will be displayed in the same browser
window.
Images can also be used as links which will be explained in the next unit.


         Self-Check Exercise 2.6.2
Do the following:
     1. Write the code to change the colour of visited links to Green, active link to Yellow.
     2. What change you will make in the code to change a normal text to a hyperlink?



       Activity 2.6.1

1.       Create Web pages that explain the Anchor tags as shown in Figures
         2.6.4 and 2.6.5.
2.       Save the first HTML file as Activity1.html and save the second HTML file as
         External.html.




Link                                                                                       2.6-14
Programming and Development Tools                        Web Programming




              Figure 2.6.4: A Web page explaining Hyperlink

The continuation of the above page is shown below:




         Figure 2.6.5: A Web page explaining Internal Hyperlink




Link                                                              2.6-15
Programming and Development Tools                                 Web Programming




          Figure 2.6.6: A Web page explaining External Hyperlink

       Technical Terminologies

Hyperlink             -
                     A Hyperlink is a text or image that is linked to a
                     location in the same Web page or to a different Web
                     page.
Internal Hyperlink - The Internal Hyperlink is a hyperlink that is linked to
                     the content in the same Web page.
External Hyperlink - The external Hyperlink is a hyperlink that is linked to
                     another HTML document.
Visited Link       - The Hyperlink of a Web page that had been visited
                     already.
Unvisited Link     - The Hyperlink of a Web page that is not visited so far.
Active Link        - The Hyperlink of a Web page that is being visited
                     currently.
Anchor Tag         - The tag (<A>) that is used to create links in Web
                       pages.


Summary
In this unit, you learnt that
           A Hyperlink is a text or image that is linked to a location in the same
           Web page or a different Web page.
           The two types of hyperlinks are Internal and External.
           The Internal Hyperlink is a hyperlink that is linked to the content in
           the same Web page.
           The tag (<A>) that is used to create links in Web pages is called
           Anchor tag.



Link                                                                        2.6-16
Programming and Development Tools                             Web Programming


          The text to be used as hyperlink is placed between the <A> and
          </A> tags.
          The values given for Href and Name attributes should be the same.
          To open the linked document in a new window, the value to be
          assigned to the Target attribute is _blank.
          The default colour of unvisited link is Blue.
          The default colour of visited link is Purple.
          The default colour of active link is Red.
          The attributes of the <BODY> tag that are used to change the
          colour of the link are LINK, ALINK and VLINK.

Assignment

I. Answer the following questions:
   1. Define Hyperlink.
   2. Name the two types of Hyperlinks.
   3. Name the tag and its attribute used to create a Link.
   4. Write the procedure to change the colour of the Hyperlinks.
   5. Write the use of Target attribute.




Link                                                                   2.6-17
Programming and Development Tools                            Web Programming



Criterion Referenced Test
Instruction: Students must evaluate themselves to attain the list of
competencies to be achieved.

Name:
Subject: Programming and Development Tools
Unit: Link

Please [ √ ] after completing the competency

Date                                           Link
                C1 C2 C3 C4 C5




Comment



Competency codes:

C1 = State the use of Link.
C2 = State the definition of Internal Link. How to use it?
C3 = State the definition of External Link. How to use it?
C4 = Change the colours of the links using the attributes of <BODY> tag.
C5 = Display a Web page in a new browser window.




Link                                                                   2.6-18

More Related Content

PDF
how-to-create-links
PDF
Basic HTML Tutorial For Beginners
PPT
Ddpz2613 topic3 linking
PPT
Ծանոթացում Gmail–ին
DOC
Web page manual
PDF
3. tutorial html web desain
PPT
902350 html jar
PPS
Kutlu Dogum Haftasi
how-to-create-links
Basic HTML Tutorial For Beginners
Ddpz2613 topic3 linking
Ծանոթացում Gmail–ին
Web page manual
3. tutorial html web desain
902350 html jar
Kutlu Dogum Haftasi

Viewers also liked (20)

PPT
Social Media For Travel & Tourism pros
PPT
H1N1 EĞİTİM Semineri
PPT
Crossing The Chasm
PPTX
Occupabilità e competitività come muoversi da protagonista nel mondo che cambia.
PPTX
Pruning cooccurrence networks
PPT
Tpcc Slideshow
PPT
Elks by Alex
PPT
NanoA
PPT
Womens Day Of Learning
PPS
Marapac
PDF
Livermore Solar Retrofit Program - EE in HOME Workshop
PPT
Product Development at the Smithsonian Institution Libraries.
DOCX
Afectar al paciente
PPT
Fotos Amsterdam
PPT
新聞整理五則
PPT
Sm For Personalbranding 10 15 09
PPTX
Posjet crvenom križu 2013
PDF
Báo Cáo Thương Mại Điện Tử VN - 2006
PPT
MeshU Cloud Camp
Social Media For Travel & Tourism pros
H1N1 EĞİTİM Semineri
Crossing The Chasm
Occupabilità e competitività come muoversi da protagonista nel mondo che cambia.
Pruning cooccurrence networks
Tpcc Slideshow
Elks by Alex
NanoA
Womens Day Of Learning
Marapac
Livermore Solar Retrofit Program - EE in HOME Workshop
Product Development at the Smithsonian Institution Libraries.
Afectar al paciente
Fotos Amsterdam
新聞整理五則
Sm For Personalbranding 10 15 09
Posjet crvenom križu 2013
Báo Cáo Thương Mại Điện Tử VN - 2006
MeshU Cloud Camp
Ad

Similar to Unit 2.6 (20)

PDF
Unit 2.9 Tables
PDF
02- Links, Structure and Layout with HTML.pdf
PPTX
Week 2 HTML lists, hyperlinks, tables, and images
PPTX
HTML Lists & Llinks
PDF
Unit 2.7 Images
PDF
2.4 Text in HTML
PDF
UNIT 2.2 Web Programming HTML Basics - Benchmark standard
PDF
Unit 2.3
PPT
Introduction html
PDF
Unit 2.5
PPTX
Links - IntraSystem and Absolute
PDF
Unit 2.10 - Frames
PPT
Lecture1and2
PPT
Hyperlink.85 to 86
PPTX
Links - IntraPage
PPT
HTML List, Nesting List & Hyperlinks.ppt
DOCX
Print this
DOC
Updated html programs
Unit 2.9 Tables
02- Links, Structure and Layout with HTML.pdf
Week 2 HTML lists, hyperlinks, tables, and images
HTML Lists & Llinks
Unit 2.7 Images
2.4 Text in HTML
UNIT 2.2 Web Programming HTML Basics - Benchmark standard
Unit 2.3
Introduction html
Unit 2.5
Links - IntraSystem and Absolute
Unit 2.10 - Frames
Lecture1and2
Hyperlink.85 to 86
Links - IntraPage
HTML List, Nesting List & Hyperlinks.ppt
Print this
Updated html programs
Ad

More from Intan Jameel (20)

PDF
1.3 Process and Information Layout
PPT
M02 un11 p02
PPT
M02 un10 p02
PPT
M02 un10 p01
PPT
M02 un09 p02
PPT
M02 un09 p01
PPT
M02 un08 p01
PPT
M02 un07 p02
PPT
M02 un07 p01
PPT
M02 un06 p02
PPT
M02 un06 p01
PPT
M02 un05 p02
PPT
M02 un05 p01
PPT
M02 un04 p04
PPT
M02 un04 p03
PPT
M02 un04 p02
PPT
M02 un04 p01
PPT
M02 un12 p01
PPT
M02 un11 p01
PPT
Unit 2.3 Part 1
1.3 Process and Information Layout
M02 un11 p02
M02 un10 p02
M02 un10 p01
M02 un09 p02
M02 un09 p01
M02 un08 p01
M02 un07 p02
M02 un07 p01
M02 un06 p02
M02 un06 p01
M02 un05 p02
M02 un05 p01
M02 un04 p04
M02 un04 p03
M02 un04 p02
M02 un04 p01
M02 un12 p01
M02 un11 p01
Unit 2.3 Part 1

Recently uploaded (20)

PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
The various Industrial Revolutions .pptx
PDF
STKI Israel Market Study 2025 version august
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PPTX
Modernising the Digital Integration Hub
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PPT
Geologic Time for studying geology for geologist
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Developing a website for English-speaking practice to English as a foreign la...
OpenACC and Open Hackathons Monthly Highlights July 2025
sustainability-14-14877-v2.pddhzftheheeeee
2018-HIPAA-Renewal-Training for executives
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Benefits of Physical activity for teenagers.pptx
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Microsoft Excel 365/2024 Beginner's training
Taming the Chaos: How to Turn Unstructured Data into Decisions
A review of recent deep learning applications in wood surface defect identifi...
sbt 2.0: go big (Scala Days 2025 edition)
The various Industrial Revolutions .pptx
STKI Israel Market Study 2025 version august
Custom Battery Pack Design Considerations for Performance and Safety
Modernising the Digital Integration Hub
1 - Historical Antecedents, Social Consideration.pdf
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
Geologic Time for studying geology for geologist
Module 1.ppt Iot fundamentals and Architecture
Credit Without Borders: AI and Financial Inclusion in Bangladesh

Unit 2.6

  • 1. Programming and Development Tools Web Programming UNIT 2.6 Web Programming Link OBJECTIVES This unit helps you to link various Web pages of a Web site using Hyperlinks. At the end of this unit, you will be able to Identify a link in a Web page. Differentiate Internal and External Hyperlinks. Open a Web page in a new Window. Change the colour of different states of a link. Benchmark standard Organize the Web site by creating links between the Web pages of a Web site successfully. Link 2.6-1
  • 2. Programming and Development Tools Web Programming Let us Revise! 1. Name the different types of list. 2. Name the tags used to create Ordered List. 3. Name the attributes of <UL> tag. 4. State how you will create Definition List. Introduction A good Web page is one which enables the user locate the information easily. Having all the contents in a single Web page is difficult. So, the content is distributed logically in different Web pages and linked to one another. Also, if a Web page is very long it will be difficult for the user to scroll the Web page to his desired location. These difficulties can be overcome by using Hyperlinks. 2.6.1 Hyperlink A Hyperlink is a text or image that is linked to a location in the same Web page or to a different Web page. You can navigate through the Web pages easily by clicking the Hyperlinks. Hands-On! The following example illustrates the use of the Hyperlink. Open the HTML file Puzzle.html in Internet Explorer. The code in Puzzle.html file is given below: <HTML> <HEAD> <TITLE> Link </TITLE> </HEAD> <BODY> <H1 Align=”Center”> Winners are Great Thinkers and Losers are Great Blinkers </H1> Solve the following puzzles and prove that you are a great thinker. <OL> <LI>Puzzles related to weight Link 2.6-2
  • 3. Programming and Development Tools Web Programming Internal Hyperlinks <UL Type="disc"> <LI><A Href="#Tomatoes">8 Tomatoes </A> <LI><A Href="#Coins">6 Coins </A> Internal Hyperlinks </UL> <LI>Puzzles related to Maths <UL Type="disc"> <LI><A Href="#Green">Green coloured cubes </A> <LI><A Href="#Multi">Multiplication and Addition </A> </UL> Internal Hyperlinks <LI>Puzzles related to logical thinking <UL Type=disc> <LI><A Href="#Triplet">Triplet Brothers </A> <LI><A Href="#Brother">Who is younger? </A> <LI><A Href="#Share">Share it equally </A> </UL> </OL> <H2> Puzzles related to weight </H2> <A Name="Tomatoes"> <H3>8 Tomatoes</H3> There are 8 identical tomatoes supplied to you. One of the tomatoes is lighter than all the other tomatoes. You are given a balance to weigh. Find the lightest tomato by weighing it 2 times only. <A Name="Coins"> <H3>6 Coins</H3> You have 6 coins of which one is heavier. Weigh them 2 times using a common balance and pull the odd one out, <A Name="Green"> <H2> Puzzles related to Maths </H2> <H3>Green Cubes</H3> Paint a cube of side 4 cm with Green colour. Cut the cube into 64 one cm small cubes. <BR> How many cubes have? <OL> Link 2.6-3
  • 4. Programming and Development Tools Web Programming <LI>No red colour on any side, <LI>One face red, <LI>Two faces red. <LI>Three faces red. </OL> <A Name="Multi"> <H3>Multiplication and Division</H3> AB multiplied by C gives DE. DE added to FG gives HI. A,B,C,...I are different digits from 1 to 9. Find A,B,C,....I<BR> <A Name="Triplet"><H3>Triplet Brothers</H3> Three triplet brothers of names Roger, Robin and Robert are sitting in a row. Roger speaks the truth, Robin Speaks lie and Robert speaks both. A man went to them and asked the person sitting left "Who is sitting in the middle?” He answered "Roger". He asked the person sitting in the middle "What is your name?” He answered "Robert". He asked the person sitting in the right "Who is sitting in the middle?” He answered "Robin". Find in which position Roger, Robin and Robert are sitting? <A Name="Brother"> <H3>Who is younger?</H3> Sister says "I am older than my Brother". Brother says "I am younger to my Sister". Atleast one of them must be lying. Who is younger? <A Name="Share"> <H3>Share it equally</H3> Three brothers are given 4 jugs of capacities 5,11,13 and 24 litres. You have 24 litres of water in 24 litre jug. Share the water equally so that each gets 8 litres of water. <BR><BR><A Href="Answers.html">Show Answers</A> </BODY> External Hyperlink </HTML> Code Sample 2.6.1 Link 2.6-4
  • 5. Programming and Development Tools Web Programming The code in Answers.html is given below: <HTML> <HEAD> <TITLE> Answers </TITLE> <BODY> <H1 Align=Center> Answers to the puzzles </H1> <H2> 8 Tomatoes </H2> Take 3 Tomatoes in each pan. There are 2 possibilities. <OL> <LI>If there is no difference in weight, take the other 2 tomatoes and put one in each pan. The one with lesser weight is the lightest of all. <LI>If there is difference, remove the tomatoes from the heavier side. Take the other 3 tomatoes and put 1 in each pan and keep one outside. If there is no difference the tomato that is kept outside is the lightest. If there is difference the lightest tomato is easily identified from the weighing. </OL> <H2> 6 Coins </H2> Take 3 coins in each pan. Remove the coins from the lighter side. Take the 3 coins from the heavier side and put 1 in each pan and keep one outside. If there is no difference the coin that is kept outside is the heaviest. If there is difference the heaviest coin is easily identified from the weighing. <H2> Green Cubes </H2> <OL> <LI> No colour on any side - 8 cubes <LI> Green colour on one side - 24 cubes <LI> Green colour on two sides - 24 cubes <LI> Green colour on three sides - 8 cubes </OL> <H2> Multiplication and Addition </H2> A=1 &nbsp; B=7 &nbsp; C=4 &nbsp; D=6 &nbsp; E=8 &nbsp; F=2 &nbsp; G=5 &nbsp; H=9 &nbsp; I=3 <H2> Triplet Brothers </H2> Left=Robert &nbsp; Middle=Robin &nbsp;Right=Roger Link 2.6-5
  • 6. Programming and Development Tools Web Programming <H2> Who is younger? </H2> Sister <H2> Share it equally </H2> The steps to be followed are: <BR> <OL> <LI> Pour water from 24 litre jug to 13 litre jug. <LI> Pour water from 13 litre jug to 5 litre jug. <LI> Pour water from 13 litre jug to 11 litre jug. <LI> Pour water from 5 litre jug to 13 litre jug. <LI> Pour water from 24 litre jug to 13 litre jug. <LI> Pour water from 13 litre jug to 5 litre jug. <LI> Pour water from 5 litre jug to 24 litre jug. </OL> </BODY> </HTML> Code Sample 2.6.2 The Web page shown in Figure 2.6.1 is displayed in the browser window. Link 2.6-6
  • 7. Programming and Development Tools Web Programming Figure 2.6.1: Web Page Showing Hyperlinks In Figure 2.6.1, the coloured texts are Hyperlinks. There are two types of Hyperlinks. They are: Internal Hyperlink and External Hyperlink. Click 8 Tomatoes. This page scrolls up to display the 8 Tomatoes puzzle in the same page. This Hyperlink is linked to the content in the same page. This type of hyperlink is called Internal Hyperlink. Try solving all those puzzles. If you cannot solve, scroll to the last line of the page. Click the hyperlink named Answers. A new Web page opens, displaying the answers to the puzzles. Here, the hyperlink Answers is linked to another Web page, which is Answers.html. This type of hyperlink is called External Hyperlink. Both Internal Hyperlink and External Hyperlink are created using <A> tag. This tag is also called as Anchor tag. Link 2.6-7
  • 8. Programming and Development Tools Web Programming Internal Hyperlink The Internal Hyperlink is a hyperlink that is linked to the content in the same Web page. The content to which the hyperlink is linked is typed in the same HTML document. Figure 2.6.2 explains the working of Internal Hyperlinks. In the Web page shown in Figure 2.6.1, there are seven hyperlinks under three sub-headings. When you click any of those hyperlinks, say 8 Tomatoes, the Web page scrolls to the 8 Tomatoes puzzle because this hyperlink is linked to the place where 8 Tomatoes puzzle is explained. The text to be used as hyperlink is placed between the <A> and </A> tags. The tag used to create 8 Tomatoes hyperlink is Figure 2.6.2: Internal Hyperlink <A Href = “Tomatoes”> 8 Tomatoes </A>. Here, HREF is the attribute that specifies to which place the document is linked. The target text of the link is preceded by another <A> tag, The <A> tag here should be used along with NAME attribute as <A Name=” Tomatoes”>. The values given for Href and Name attributes should be the same. Lab Exercise Lab Exercise 1: Open D6_1.html in Internet Explorer. The following code will be present in D6_1.html. <HTML> <HEAD> <TITLE> Menu Choices </TITLE> <A Name="TOP"> <H1 Align="CENTER"> Menu Choices </H1> </HEAD> <BODY > <H1> <A Href="#MEAT"> Meat Dishes </A> <BR><BR> <A Href="#SEAFOOD"> Seafood Dishes </A><BR><BR> Link 2.6-8
  • 9. Programming and Development Tools Web Programming <A Href="#VEG"> Vegatable Dishes </A><BR> </H1> <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> <H2 Id="MEAT"> Meat <BR> </H2> <UL> <LI> Beaf <BR> <LI> Chicken <BR> <LI> Deer <BR> <LI> Lamb <BR> <LI> Turkey </UL> <H6 Align=CENTER><A Href="#TOP">Back to Top </A></H6> <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> <H2 Id ="SEAFOOD"> Seafood </H2> <UL> <LI> Crab <BR> <LI> Cattle Fish <BR> <LI> Fish<BR> <LI> Oyster <BR> <LI> Prawn <BR> </UL> <H6 Align=CENTER><A Href="#TOP">Back to Top</A></H6> <BR><BR><BR><BR><BR> <H2 Id ="VEG"> Vegetables </H2> <UL> <LI> Brocolli <BR> <LI> Carrot <BR> <LI> Cabbage <BR> <LI> Cauliflower <BR> <LI> Potato </UL> <H6 Align=CENTER><A Href="#TOP">Back to Top </A></H6> Link 2.6-9
  • 10. Programming and Development Tools Web Programming </BODY> </HTML> 1. Identify the tag which is used to create link? 2. Name the attribute which is used specify the document to which the hyperlink is linked to? Lab Exercise 2: Open Malaysia.html that you have created under the folder in your name in C:. 1. When you click on the text “National Flower”, the following description should be displayed in the same page using internal hyper link. National Flower Bunga Raya (hibiscus) is the national flower in Malaysia. No one knows when it’s introduced to Malaysia. It is originated in Asia and the Pacific Islands. Hibiscuses are found in many difference colours and colour combinations. But Malaysian has chosen the red five-petalled types as their national flower. It is also used for medicine and cosmetics, for dyeing the hair and eyebrows. Some of them still use the roots of the flower as a cure for fever. The petal can be used for polishing shoes. 2. When you click on the text “Fruits of Malaysia”, the following description should be displayed in the same page using internal hyper link. Fruits in Malaysia Durian Durian is called the King of fruits. Durian is a big, green thorny fruit. The Malaysians love this fruit even the foreigner like the taste. It is cultivated in all parts of Malaysia. The fruit can be made into durian cake, durian powder and jam. Star Fruit Another local fruit is star fruit. It has a greenish to yellowish colour. When you cut the fruit across it, it will look like a star. The fruit can be made into jam, jelly and fresh juice. External Hyperlink The external Hyperlink is a hyperlink that is linked to another HTML document. Figure 2.6.3 explains the working of External Hyperlinks. Link 2.6-10
  • 11. Programming and Development Tools Web Programming Figure 2.6.3: External Hyperlink In the Web page shown in Figure 2.6.1, the hyperlink Answers is linked to the HTML document named Answers.html. When you click the Answers hyperlink, the Answers.html document opens in the browser window. The tag used to create Answers hyperlink is <A Href = “Answers.html”> Answers </A> Here, Href is the attribute that specifies the document to which the hyperlink is linked. Note There is no difference in the appearance of Internal Hyperlink and External Hyperlink. Tip It is possible to create links to any other Web site from your Web page. Lab Exercise Lab Exercise 3: Open D6_2.html in Internet Explorer. The following code will be present in D6_2.html. Link 2.6-11
  • 12. Programming and Development Tools Web Programming <HTML> <HEAD> <TITLE> Hyper Link </TITLE> <H1 Align="CENTER"> Hyper Links </H1> <HR> </HEAD> <BODY Bgcolor="PINK" Text="#FF00FF" Link="#FF0000" Vlink="#000080" Alink="#800080" > <H3> <A Href="http:yahoo.com">Click here to go to Yahoo</A><BR> <A Href="http:google.com">Click here to go to Google</A><BR> <A Href="http:microsoft.com">Click here to go to Microsoft</A><BR> </H3> </BODY> </HTML> 1. Identify the tag which is used to create link in source code D6_2.html. 2. Underline the attribute which is used with the <A> tag to specify the name of the file to be linked to. 3. Name the attribute which is used to sets the colour for active links, visited links and hyper links in source code D6_2.html. Lab Exercise 4: Open D6_2.html in Internet Explorer. 1. View the source code in notepad. 2. Apply the active link colour to Maroon. 3. Apply the visited link colour to Yellow. 4. Apply the hyperlink colour to Green. 5. Save the file and view the output in the browser. Lab Exercise 5: Open Malaysia.html that you have created under the folder in your name in C:. 1. When you click on the text “States of Malaysia”, the “States.html” which you have created under the folder in your name in C: should open in new window. 2. When you click on the text “Festival”, the “Festivals.html” which you have created under the folder in your name in C: should open in new window. 3. When you click on the text “Whether and Climate in Malaysia”, the “Climate.html” which you have created under the folder in your name in C: should open in next window. Link 2.6-12
  • 13. Programming and Development Tools Web Programming Self-Check Exercise 2.6.1 Correct the following wrong sentences: 1. Images cannot be used as Hyperlinks. 2. The External Hyperlink is a hyperlink that is linked to the content in the same Web page. 3. In case of External Hyperlink, the content to which the hyperlink is linked is typed in the same HTML document. Changing the Colour of the Link The hyperlink is distinguished from ordinary text by the colour. There are three states of a link. They are The link that has not been visited earlier, The link that is being visited and The link that had been already visited. These states are identified by the colour of the link. The default colours of a link in 3 different states are given in Table 2.6.1. State of Link Default Colour of Link Unvisited Link Blue Link being visited Red Visited Link Purple Table 2.6.1: Default colours of a link In Figure 2.6.1, the first link is purple in colour which means it is a visited link. All the other links are blue in colour which means they are not visited so far. The colour of the links can be changed using the attributes of the <BODY> tag. The attributes used to change the colour of the links in different states are given in Table 2.6.2. State of Link Attribute Unvisited Link Link Link being visited Alink Visited Link Vlink Table 2.6.2: Attributes of <BODY> tag to change the colour of a link Note Alink stands for Active Link and Vlink stands for Visited Link. Link 2.6-13
  • 14. Programming and Development Tools Web Programming For example, the following code displays the colour of active link in Green, unvisited link in yellow and visited link in Magenta. <BODY Link=”Yellow” Alink=”Green” Vlink=”Magenta”> Anchor Tag and Target Attribute The Target attribute can also be used within the anchor tag. This attribute specifies where the linked document should be opened. To open the linked document in a new window, the value to be assigned to the Target attribute is _blank. For example, to open the Answers.html document in a new window the code is <A Href = “Answers.html” Target = “_blank”> Answers </A>. Note In the absence of Target attribute, the Web pages will be displayed in the same browser window. Images can also be used as links which will be explained in the next unit. Self-Check Exercise 2.6.2 Do the following: 1. Write the code to change the colour of visited links to Green, active link to Yellow. 2. What change you will make in the code to change a normal text to a hyperlink? Activity 2.6.1 1. Create Web pages that explain the Anchor tags as shown in Figures 2.6.4 and 2.6.5. 2. Save the first HTML file as Activity1.html and save the second HTML file as External.html. Link 2.6-14
  • 15. Programming and Development Tools Web Programming Figure 2.6.4: A Web page explaining Hyperlink The continuation of the above page is shown below: Figure 2.6.5: A Web page explaining Internal Hyperlink Link 2.6-15
  • 16. Programming and Development Tools Web Programming Figure 2.6.6: A Web page explaining External Hyperlink Technical Terminologies Hyperlink - A Hyperlink is a text or image that is linked to a location in the same Web page or to a different Web page. Internal Hyperlink - The Internal Hyperlink is a hyperlink that is linked to the content in the same Web page. External Hyperlink - The external Hyperlink is a hyperlink that is linked to another HTML document. Visited Link - The Hyperlink of a Web page that had been visited already. Unvisited Link - The Hyperlink of a Web page that is not visited so far. Active Link - The Hyperlink of a Web page that is being visited currently. Anchor Tag - The tag (<A>) that is used to create links in Web pages. Summary In this unit, you learnt that A Hyperlink is a text or image that is linked to a location in the same Web page or a different Web page. The two types of hyperlinks are Internal and External. The Internal Hyperlink is a hyperlink that is linked to the content in the same Web page. The tag (<A>) that is used to create links in Web pages is called Anchor tag. Link 2.6-16
  • 17. Programming and Development Tools Web Programming The text to be used as hyperlink is placed between the <A> and </A> tags. The values given for Href and Name attributes should be the same. To open the linked document in a new window, the value to be assigned to the Target attribute is _blank. The default colour of unvisited link is Blue. The default colour of visited link is Purple. The default colour of active link is Red. The attributes of the <BODY> tag that are used to change the colour of the link are LINK, ALINK and VLINK. Assignment I. Answer the following questions: 1. Define Hyperlink. 2. Name the two types of Hyperlinks. 3. Name the tag and its attribute used to create a Link. 4. Write the procedure to change the colour of the Hyperlinks. 5. Write the use of Target attribute. Link 2.6-17
  • 18. Programming and Development Tools Web Programming Criterion Referenced Test Instruction: Students must evaluate themselves to attain the list of competencies to be achieved. Name: Subject: Programming and Development Tools Unit: Link Please [ √ ] after completing the competency Date Link C1 C2 C3 C4 C5 Comment Competency codes: C1 = State the use of Link. C2 = State the definition of Internal Link. How to use it? C3 = State the definition of External Link. How to use it? C4 = Change the colours of the links using the attributes of <BODY> tag. C5 = Display a Web page in a new browser window. Link 2.6-18