12.18.03

When And How To Hyperlink To An Area On The Same Page

By BasicTemplates

You know how to create a standard hyperlink, right? If not, here is a quick review:

Relative Path:
<a href="mypage.html">My Page</a>

Absolute Path:
<a href="http://www.yoursite.com/mypage.html">My Page</a>

But what do you do if you wanted to link to a specific spot on the same page? And in what cases would you want to?

I'll answer the latter first, because when I tell you how to do it, it will make more sense if you knew under what circumstances you might want to use this feature.
Why would you want to link to an area on the same page (called an anchor tag)? If you want to link to a specific location going from mypage.html to anotherpage.html. Rather than send your visitors to the top of anotherpage.html, you can be specific as to exactly where you want their browser to direct them on the page where you send them.

If your pages are long, you can break up the long-scroll problem by using the anchor tag. Place your section names at the top hyperlinked to the anchors you placed within specific areas in your source code. This helps your visitors get to the areas of a l-o-n-g page quickly.



Get JavaProNews Newsletter Free
-
">Click Here


When you want to link to a specific area on a page, you need to do two things.

State the exact location of the specific area in your HTML source code and name it. We named this location "gohere", but you can name it whatever you like that makes sense to you:

<a name="gohere"></a>

Then hyperlink to the area you called "gohere" by using the code below. Note that we used a # tag before the name of the specific location. This # character is called an anchor. This takes the place of a standard page name as shown in the absolute and relative path examples at the beginning of this article when link to a location on the same page.



<a href="#gohere">Go Here</a>

What if you want to link to a specific area on a different page? That's easy. Combine the two techniques. Your hyperlink code will look like this:

Relative Path:
<a href="anotherpage.html#gohere">Go Here</a>

Absolute Path:
<a href="http://yoursite.com/page2.html#gohere">Go Here</a>

Related Article: The Cure for L-O-N-G Web Pages

About the Author:
Sean Burns is the author of the WebmastersReference.com Newsletter - http://www.webmastersreference.com/newsletter. More than five years of experience in site design, marketing, income generation, search engine optimisation and more is passed on to subscribers - hype free. Sign up today to get real information of real value to webmasters.


Read this newsletter at: http://www.devwebproin.com/2003/1218.html

Free Newsletters
Part of the iEntry Network
over 4 million subscribers
DevWebProIndia
DesignNewz
FlashNewz


Send me relevant info on products and services.




From the Forum:
Redirecting within a domain

What is it called, where a domain is a subdomain of another domain?

I have a server, with virtual domains (I think that is what they are called - 100 domains on one server, with one IP address). So I can set up www.mydomain.com on my server, with no problem.

Click here


-- DevWebProIndia is an iEntry, Inc. publication --
 © 2003 iEntry Inc.  All Rights Reserved  Privacy Policy  Legal 

advertising info | news headlines | free newsletters | comments/feedback | submit article