Webpage Workshop: Home » XHTML » Links within a document

Links within a document

Sometimes when you visit a website there is a link at the bottom of the page that reads "back to top", or when you enter the page it jumps half way down to a particular point on the page. This is done using markers within the linked page.

To use these links you first have to set the marker in the page that you want to link to. You do this using code like the example below:

<a name="marker"></a>

Notice that in the above example, there is no text in between the anchor tags. This is because use of this anchor element has no effect on the way that the page actually looks. The name attribute specifies the name of the location that we will link to.

Now to link to that location you use a very similar style of link to the ones shown in the previous tutorial. In this case though, there is an extra little bit added to the end of the URL.

<a href="page.html#marker">Link text</a>

The link looks near enough the same, but the addition of #marker to the end of the URL is what makes all the difference. In the case of the example above it specifies that the link should point to the location "marker" on the page "page.html".

In the next tutorial we will discuss how you can split your text up into paragraphs and specify when text should begin a new line.

<< Previous page | Next page >>