Wednesday, 24 February 2010

Anatomy of a link

So a client (Hi Mark) was asking how a link could point out of his site but open in a new window and this got me thinking about the nature of hypertext. I'm not 100% sure that we should be encouraging such branching. If you imagine a browse on the internet as a journey then each time a new page is opened in a new window (or tab) then the path forks and the site of that branching becomes something of a node allowing the journey to start afresh from when the forking occurred. Almost like a save-game in a platform'r - it allows the traveller to drop a fruitless avenue and start again, perhaps it isn't such a bad thing after all?

Anyway a link is structured like this:

<a href="" target="_blank">DRMSite</a>

The "href"attribute of the "a" element is the URI to which the link points, the "target" attribute tells the browser where the link should be opened (in the example above it will open in a new browser window, creating another strand of the journey).

It is possible to use a "a" element in another way. In documents where there is a lot of content then we can use the "a" element to navigate between the content using named anchors, funnily enough we do this using the "name" attribute.

<a href="#Section01">Jump to Section 1</a>

This refers to an internal link and so long as Section 1 is marked up thus:

<h2><a name="#Section01">Section 1</a></h2>

Then all will be fine and dandy.

Still feels a little like cheating though ;-)


We won the quiz last night!

No comments:

Post a Comment