This article originally appeared on the website "Professionals in Pajamas"
which has now been incorporated into Widget Inc.



HTML 101 - Part 3: Going Somewhere

Roger L. Main

The fact that you're reading this means you probably already have a good idea of what a link is. Maybe you went to Google and typed in "work at home" and were directed to this site. Perhaps another web page recommended this site and told you to "click here" and when you did - bingo, you arrived at Professionals in Pajamas. What you clicked on was a link - one of the things that divides a web page from a text document. Links cause your browser to go somewhere else, either within the general site (such as a different page on professionalsinpajamas.com) or to another site, entirely.

So, how does this work? It's not magic, it's HTML and, like everything in HTML it's all in the tags. The link tag looks like this:

<a href='http://www.somewebsite.com'>Click me</a>

The link tag is a bracketed tag which surrounds whatever it is that you want the viewer to be able to click on to go somewhere (in the example above, it would take you to www.somewebsite.com which, at the time of this writing doesn't exist). It can be text or graphic. The default for text, to show that it's a link, is to underline it. For graphics there's a border around it. You can change this in the graphics tag by setting the value of the "border" attribute, such as border=0 to denote that there should be no border. With most browsers, the mouse cursor changes also when hovering over a link.

Again, like with most tags, there are a plethora of attributes which you can specify, but there's only one that we'll look at, here. It's the "target" attribute. What this does is specify where the link page will show up. By default, the new page will show up in the same viewer space as the page you're leaving (ie: the same browser window or, if you're using frames in the same frame). If your link is in a frame, you can specify for the new page to occupy the parent frame by saying "target=_parent" or, if you want the new page to override all of the frames and take up the entire window, say "target=_top".

You can also get the new page to open a new browser window. There are two ways: "target=_blank" and "target=anynameyouwant". What's the difference? Well, if you have multiple links on your page and you specified _blank then each time the user clicks a link the new page will open in a new browser window. If you use a name, then you can use the same name over and over to specify the same, newly opened browser window. It's also useful for scripting, but that's a whole different series.

Got that? Okay, you got me. I did say last time that we'd talk about getting the page to "do something" but that's going to have to wait because you've probably also noticed that I've been talking about frames and yet I haven't said what a frame is. That's for next time.

Return to the main menu



© Copyright 2002-2007 Widget Inc.
All Rights Reserved