Hyperlinks
in HTML
Hyperlinks
are used to create links that allow the users to navigate from one page to
another. To create hyperlinks use <a>
element. This element has the attribute href to specify the url of the document to display when user
click on that hyperlink. It has the attribute target to specify where to display the linked document of
the hyperlink and it has the possible values _blank to display the linked document in new window or tab, _top opens the linked document in
complete body of the current window, _parent
opens the linked document in parent frame, _self opens the linked document
in same frame or window and specifying a framename opns the linked document in the specified frmae.
Example
: The
following example demonstrates how to create hyperlinks
<!doctype html><html><body><a href=”first.html”> First.html </a><br/><br/><a href=”Heading.html”> Heading.html </a><br/><br/><a href=”Table.html”> Table.html </a></body></html>
Named
Anchors
Named
anchors are the anchors that created by specifying a name to it and purpose of
named anchors is to allow the users to navigate to a particular location in a
document. To create a named anchor use name attribute of <a>
element. To create a hyperlink to a named anchor for the href attribute you have to
specify the name of the anchor prefixed with # symbol.
Example : The following example demonstrates how to use named anchors to allow the users to navigate to a particular location in the document.
<!doctype html>
<html><body><a name=”Top”></a><a href=”#C1”> <h1>Chapter1</h1></a><a href=”#C2”> <h1>Chapter2</h1></a><a href=”#C3”> <h1>Chapter3</h1></a> <br/><br/><a name=”C1”></a><a href=”#Top”>Top</a> <br/><br/><h1>Chapter1</h1><p> Provide some content for chapter1 with 20 to 30 lines </p> <br/><br/><a name=”C2”></a><a href=”#Top”>Top</a> <br/><br/><h1>Chapter2</h1><p> Provide some content for chapter2 with 20 to 30 lines </p> <br/><br/><a name=”C3”></a><a href=”#Top”>Top</a> <br/><br/><h1>Chapter3</h1><p> Provide some content for chapter3 with 20 to 30 lines </p> <br/><br/></body></html>
Example
: The
following example demonstrates how to create hyperlinks from one document to
another to a specific location in the other document.
<!doctype html><html><body><a href=”NamedAnchors.html#C1”> Chapter1 </a> <br/><br/><a href=”NamedAnchors.html#C2”> Chapter2 </a> <br/><br/><a href=”NamedAnchors.html#C3”> Chapter3 </a> <br/><br/></body></html>
Setting the color to the hyperlink
We can set the color to the hyperlink by using link
attribute of body tag.
Whenever we want to give the special color to the
visited links than we have to use vlink attribute of body tag.
If we want to change the color of the hyperlinks at
the time of visiting that link than we are going to use alink attribute of body
tag.
Example:
<html><body link=’red’Alink=’cyan’Vlink=’green’><a href = ‘abc.html’> click here </a><br></body></html>
No comments:
Post a Comment