Saturday, November 13, 2010

Internal linking!

I've taught myself something new. I can now link to an arbitrary point in the middle of a page or post, rather than just the top of the post. How? With a little snippet of code that looks like this:


<span id="name"></span>

where name is the name I am assigning to the link.

I then link to it with the following modification of the standard link code:

<a href="http://amateurgeek.blogspot.com/2010/11/internal-linking.html#name">link text here</a>

When I implement that in actual html, it looks like this: link text here and it links to the span tag that I put just above the sample code. Try the link to see what I mean.



So, I can link to the middle of pages. How is that useful? Well, check out the links at the bottom of the page. Say, I want to link to my comment policy, which is halfway down the massive infopage. If I link to the page, it's hard to find. If I link directly to the section, it's real easy.

Wikipedia also uses a similar system when dividing up pages. It means you can link to any section of a page, including when doing internal links. Very convenient.

No comments: