The html code is the same whether you attach it to a piece of text or an image.
It starts with the tag a href= followed by the destination page within quotes.
The Path
The hardest part about learning to make links is stating the path. You can use either an absolute or a relative path, depending upon the location of the file and your own preferences.
Absolute path
Use this always when you are leaving your site, as in: Please go to google.
Relative path
This can only be used when you are linking to a page within your own site. For example, I could use this simple relative link, or even a more complex link to another directory that is still relative.
Links Within The Page
Links can be written to navigate within a same html page. The tag is the same (a href= ) but the destination is the number sign followed by the name of the destination id within quotes, i.e. "#construction".
<a href="#mylink"> or <a href="http://www.reifman.com/class/wwwtemp.html#isp">
The destination is pointed out by declaring an id:<a id="construction"> </a>
Look at the document source on page How the web works for an example.
Images as Links
This works just like the text version of links. The one thing to look out for is that html automatically puts a border on an image that's a link unless you specify no border in the image tag or the style declaration.
These pictures of Elvis Presley can take you to an Elvis site, or this text can.
Tags have properties.
They are included within the tag and help to further define the function and behavior of the tag. For example, font tags can have many properties: size, family, etc. etc. So can the <A> or link tag. Some of the A tag properties include:
- Href="the link"
- Name
- Target (if you don't specify it will just load into the same window as the link is in. If you specify a window name, it will create a new window if that one does not currently exist) and then there are the reserved target names below:
- TARGET="_blank" This target will cause the link to always be loaded in a new blank window. This window is not named.
- TARGET="_self" This target causes the link to always load in the same window the anchor was clicked in. This is useful for overriding a globally assigned BASE target.
- TARGET="_parent" This target makes the link load in the immediate FRAMESET parent of this document. This defaults to acting like "_self" if the document has no parent.
- TARGET="_top" This target makes the link load in the full body of the window. This defaults to acting like "_self" if the document is already at the top. It is useful for breaking out of an arbitrarily deep FRAME nesting.
- Title