HTML Lesson 4 -- July 18 - CIS 228 -

Download Report

Transcript HTML Lesson 4 -- July 18 - CIS 228 -

Hyperlink
● Anchor tag and its attributes
● Four Types of URL
─ Email
─ Absolute addressing
─ Relative addressing
─ Intrapage
● Attributes -- link, vlink, alink
● Anchor tag with image
Anchor Tag and its Attribute
 Hyperlink or Anchor is represented
by text or image that is linked to
another Web page, either on the
same site or in another Web site.
Clicking on the link will take the user
to another Web page, or to another
place on the same page.
 To create a link, use anchor tag and
href attribute
<a href=“addressOftheWebpage”> text/image </a>
Email Link
 Text is used as email link
<a href=“mailto:[email protected]”>
Click here to my email
</a>
 Image is used as email link
<a href=“mailto:[email protected]”>
<img src=“EmailPic.gif” alt=“Email”>
</a>
Absolute addressing Link
 Absolute addressing is entire path of
where a file exists; Full description of
the address
– Absolute address of a Web page on
the internet
http://comet.lehman.cuny.edu/priya
– Absolute address of a Web page on a
local system
A:/Webfolder/index.html
Relative addressing Link
 Relative addressing is a special
addressing method that applies only
when the address you'd like to link to
is on the same server or system as
the web page that the link appears.
 Relative addressing requires only a
partial pathname.
 This partial pathname only needs to
contain enough information to set it
from the current directory to the file
you’d like to link to.
Relative addressing Link
 The simplest example would be the
case where the webpage you’d like to
link to are in the same system and
directory.
<a href=“RelativeLink.html”>my link</a>
 Partial pathname is expressed in
notations
–\
– ..\
– .\
go to the main directory
go one directory up in hierarchy
the current directory
Intrapage Link
 Intrapage link directs or goes to a
particular spot on a given Web
page
 Two parts to Intrapage link
– Naming a region
– Linking to the region
Intrapage Link
Naming a Region
 For an intrapage to work, we need to
name the position within the page
that we’d like to go.
 To name a region within a Web page,
we use the anchor tag with a name
attribute.
<a name=“AssignNameValue”>
my region
</a>
Intrapage Link
Linking to the region
 To link to an identified region, use the
anchor tag and href attribute.
 The value for the href attribute must
begin with a hash or pound symbol,
followed by the name of the region
<a href=“#UseAssignedNameValue”>
Go to a particular region
</a>
Attributes -- link, vlink, alink
 link, vlink, alink are attributes of body
tag. Each effects the color of links at
different stages.
 link attribute effects the color of an
unvisited link
 vlink attribute effects the color of a
visited link
 alink attribute effects the color an
activated link
<body link=“blue” alink=“red” vlink=“purple”>