Hyperlink
Hyperlink
INTERNET TECHNOLOGIES 1
LESSON 8: HYPERLINK
Objectives:
At the end of the lesson students are able to:
1. Identify what is hyperlink.
2. Analyze how to use the anchor tag
3. Create a simple program using anchor tag
Hyperlinks
• Hyperlink, usually shortened to link, is a direct reference within a hypertext document.
• The area from which the hyperlink can be activated is called anchor.
Anchor Tag
• With the attribute href (hypertext reference), the anchor becomes a hyperlink to either another
part of the document or another resource (e.g. a webpage) using an external Uniform Resource
Locator (URL).
• The attribute title may be set to give brief information about the link:
•
Alternatively (and sometimes concurrently), with the name or id attributes set, the element
becomes a target. A URL can link to this target via a fragment identifier. Any element can now
be made into an anchor by using the id attribute, so using <a name="food"> is not necessary.
Where:
Values:
• _self – to open the target URL in the same frame as it was clicked
• _ top – to open the target URL in the full body of the window
• name – defines an internal bookmark of the page. This is for linking to a specific part of the page
In most graphical browsers, when the cursor hovers over a link, it typically changes into a hand with a
stretched index finger ( ), and the title appears in some way (varies according to browser). Some
browsers render alt text the same way, though this is technically incorrect.
WEB DEVELOPMENT AND
INTERNET TECHNOLOGIES 3
• The HTML anchor element <a> is used to define both hyperlinks and anchors.
• The term HTML link is used when the <a> element points to a resource and the term HTML
anchor when the <a> elements define an address inside a document.
• Link syntax:
• The start tag contains attributes about the link. The element content (Link text) defines the part
to be displayed.
• Note: The element content does not have to be a text. You can link from an image or any other
HTML element.
• The href attribute defines the link "address". This <a> element defines a link to W3Schools web
page:
• The target attribute defines where the linked document will be opened. The code below will
open the document in a new browser window.
WEB DEVELOPMENT AND
INTERNET TECHNOLOGIES 4
• When the name attribute is used, the <a> element defines a named anchor inside a HTML
document. Named anchor are not displayed in any special way. They are invisible to the reader.
WEB DEVELOPMENT AND
INTERNET TECHNOLOGIES 5
URL Encoding
• URL encoding converts characters into a format that can be safely transmitted over the
Internet. URL means Universal Resource Locator.
• Web browsers request pages from web servers by using a URL. The URL is the address of
a web page i.e. http://www.ilearntechnologies.com.
• URLs can only be sent over the Internet using the ASCII character-set. Since URLs often
contains characters outside the ASCII set, the URL has to be converted. URL encoding
converts the URL into a valid ASCII format.