|
Page anchorsIt is very easy to make page anchors and once you get use to creating links, this is a breeze. If you don't know what page anchors are, they are links on a page that links to certain sections of the page. We will create a step by step guide for you to learn to create your own page anchors. First you will need to name a set of text by using this code:
<a name="textname">Text</a>
The name="" variable will give a name to your text in between the <a> and </a> tags. You will need to insert the name that you want to name your text in between the quotations. So the above name is textname. If we wanted to link to this, we would use the code below:
<a href="#textname">Text</a>
This is the code that links one page to another, but in this code, there is not http:// or others, it uses the # (number sign). It tells the browser to look for the link named textname. This is how the example code will look and operate: It is really simple and throughout our page, we have used page anchors to allow the user to browse faster and more easily. Page anchors are great for long pages that have a lot of content. What happens if you are trying to link to a page anchor from another page? It is fairly simple, let's pretend if we are currently on another page and are trying to link to textname on this page. We would use this code:
<a href="http://www.mysite101.com/programming/html/links-anchors.html#textname">Text</a>
You can see that we just placed the # (number sign) after the page the page anchor is located on and added the name of the page anchor after it. Of course, if you are in the same folder or would like to use relative or absolute pathnames it would still work as long as you add the # sign and the name of the page anchor after the # sign. The outcome would look like the outcome below, but we will show it once more just for you to see: |