Web beginners are usually surprised to learn, as I was, that all the wondrous interactive entities on the internet are comprised of strings of plain old text. In fact, you can make web pages using any text editor. Hyperlinks and other webby goodness are special sequences of text that the browser knows to interpret as instructions. By writing out these strings of characters, you can embed links in your e-mails, blog posts and any other text that winds up on the web.
To make a hyperlink, you need to specify for the computer what text you want to link and which item on the web you want it to link to. The only hard part is that you have to give the browser this string of information in a very particular and counterintuitive order. Let’s start with the text that’s going to become the link:
This text links to a destination.
To inform the browser that this text is special, you surround it with so-called anchor tags. Why ‘anchor’? Take it up with Tim Berners-Lee if you need a meaning; otherwise, this is one of those baffling pieces of tech terminology to just serenely accept. The anchor tag is an ordinary lowercase letter ‘a’.
aThis text links to a destination.a
You, the human reader, can infer from grammatical context that the anchor tags aren’t part of the regular text. Computers are more literal-minded than you, and they need further instruction. To set the tags apart from the text, you surround them with triangle brackets.
<a>This text links to a destination.<a>
Web convention further requires that you distinguish the beginning of the link from the end of it, by adding a slash to the closing tag.
<a>This text links to a destination.</a>
What if you wanted to use triangle brackets or slashes in the text itself? Not such a hot idea. You need to use a bunch of ugly control codes that plunge you into an Escher-like recursive spiral. Hypertext Markup Language uses the triangle brackets precisely because they don’t come up much in ordinary discourse.
Anyway, you’ve succeeded in identifying your soon-to-be-hyperlinked text. So far, so good. Now you need to tell the browser where your link points to. This you do by adding some modifiers to the opening anchor tag: href, short for ‘hypertext reference’, an equals sign, which means what you think it means, and the destination address, like so:
<a href=www.destination.com>This text links to a destination.</a>
Except that the destination needs to be in quotation marks, and you need to give the exhaustively full web address, starting with the acronyms for ‘hypertext transfer protocol’ and ‘world wide web’, because back in internet prehistory there were various other transfer protocols and non-web regions of the internet. Again, it would be nice if you could trust the computer to just infer what you mean from context, but computers are dumb. So here’s the correct and fully-functional link:
<a href=”http://www.destination.com”>This text links to a destination.</a>
I’ve been writing my own hypertext markup language for ten years now, and I still have a hard time keeping all the steps straight. To make link writing manageable, I find it helpful to use placeholders. Here’s how I make links to my personal site in real life. First I write:
<a href=”foo”>This text links to my site.</a>
Then I go back and replace ‘foo’ with the destination address:
<a href=”http://www.ethanhein.com”>This text links to my site.</a>
The most annoying thing about computers is their extreme blindness to context. If you leave out even one of the quotation marks or slashes or brackets in your hyperlink, it becomes totally broken. I’m an artsy type and fine attention to typographic detail is not my strong suit, but computers are unforgiving in this regard.
So there we go. In case you’re wondering, you don’t need permission to link to something. Any address in the location bar at the top of the browser window is fair game, just copy and paste it in place of foo. I personally am delighted when people link to me, because it drives traffic to me, and makes me come up higher in Google searches. Go forth and hyperlink!