Home / code / html

Links in HTML.

Links, this is used when you want to link to other pages, files, news groups and more.
Here is a list of possible links.
You have to put them in the URL-part.
<a href="URL">name</a>

Link to Looks like Example
WWW-page http://domain-name/directory/filename http://www.cnbc.com/news/news/cnbcnews.html
Local system file:///drive/directory/filename file:///c:/windows/spec.html
e-mail address mailto:firstname.name@provider.com mailto:Jan.vankraineveld@hotmail.com
Usenet-newsgroup news:newsgroup news:soc.culture.belgium
Anomic ftp-server ftp://domain-name/directory/filename ftp://ftp.cuteftp.com

We are going to talk here about the http:// links.
For mail links go here.

We already told you that http:// links to other pages.
A normal link looks like this:
<a href="http://www.domainname.com/directory/filename.html">linkname</a>

Now when you link to page on your own site you can type the entire URL. But, when you change servers you well need to rename every link you have placed on your site. Not good
Now when you link to a page in the same directory on your site you only need to type the filename.
Like this:
<a href="filename.html">linkname</a>

What if you want to link to a page in a different directory?
If you want to link from index.html to page.html and,
index.html is in home/index.html and
page.html is in home/mypages/page.html.
The link looks like this:
<a href="mypages/page.html">linkname</a>

Now if you want to link from page.html to index.html
The link looks like this:
<a href="../index.html">linkname</a>

This way you don't need to change the links when you transfer to a new host.
And it takes less space.

You can also link to parts of a page.
A link looks then like this:
<a href="#namedestination">linkname</a>

You have to add this on the place where you want the link to go.
<a name="namedestination">name of the destination</a>

The name of the destination is usually a title of a paragraph.

You can also link to a place in a document:
<a href="filename.html#namedestination">linkname</a>

OK we have had that, now when you click on a link it opens in a the same window but it doesn't have to be that way.
<a href="" target="***|_blank|_self|_parent|_top"></a>

  • *** Stands for name, you can let the link open in a window or frame with the name.
    You will see more of this in frames and javascript.

  • _blank Opens the link in a new window.

  • _self Opens the link in the same windows. Standard.

  • _parent Opens the link in the parent window.
    You'll see this when you use frames.

  • _top Opens the window in the top window.
    Like with frames, when the window is divided in different parts.
    A top-link opens in the entire window.

There are more, like _START and WINDOW. But they are not supported by all browsers.
I wouldn't use them.



Latest script: