HTML BASICS STUDIES FOR STUDENTS
HTML Basics Description
5. Links
Absolute Links
or Links to Other Pages
<a href=”http://the_URL”>Words
to Underline</a> The anchor
tag - absolute
The text in between the two tags is underlined. When the user clicks on it the browser
transfers to the URL in the first tag.
NOTE: the quote marks are the usual ones --- not
facing in any particular way.
<a href=”http://www.ignoufriend.co.in”>My
Favorite Professor Navneet Vishwas</a>
This example (above) is an absolute reference.
Notice that it gives both the protocol (HTTP ---- as
opposed to FTP etc.) and the complete address.
Notice that the complete address is enclosed in
quotation marks.
There is a convention that when a path name is
listed (as above) without a file name at the end, then the browser will look
for a file called index.htm or index.html. So your opening page should be named
index.
There is also a convention that user directories (those
that start ~username) will
have all
their public files in a directory called public_html.
In other words,
when a viewer clicks on the text in the example, her browser will
actually get the file www.ignoufriend.co.in/public_html/index.htm
In this case (the absolute URL) the URL completely defines where the browser
is to go.
Links to
Places on the Same Page
<a href =”#NamedSpot”>Words to Underline to go up or down the page</a>
<a name =”NamedSpot”
id=”NamedSpot”>Where link will go</a>
The anchor tag – same page (using the NAME attribute)
In order to link somewhere else on the same page you
need two anchor tags –
<a name=”ShortNameForTheSpot”>Text to
link to</a>
defines a name for the place you wish to
go to.
<a
href=”#ShortNameForTheSpot”>Text to click on to go there</a>
does
the actual linking.
Notice
that both the a name= tag and the a href= tag have the address in quotation
marks.
In XHTML1 and in HTML4 you did not need the id= part, but beginning in
HTML5
you need the id= and further if there is both a name (for legacy browsers) and an
id then they have the same value.
you need the id= and further if there is both a name (for legacy browsers) and an
id then they have the same value.
Notice the use of # inside the anchor where the linking is done ---this alerts the browser
to look for a named place, not an absolute or (see below) relative reference.
Your link may go either up or down the page. See the links8a.html and links8b.html
examples.
You may also combine links to other pages and links
to named spots on those other pages.
For example, let us suppose that you have built a page at with the URL
SomeComputer/MyBook/Intro.html
And that somewhere in that
file you have a named anchor
<a name=”contents”>Table of
Contents</a>
Then, on some other page, if
you wish to link to the Table of Contents you would code:
<a href=”http://
SomeComputer/MyBook/Intro.html#contents”>MyBook’s Table of Contents</a>
Notice that there is the usual anchor with an href
(in quotes) but that the #namedSpot
comes at the end of the URL.
Relative Links
or Links to Other Pages on the Same Site
<a href=”OtherFileInSameDirectory.htm”>Check Out My Other Pages</a>
No comments:
Post a Comment