|
Microsoft
Office Training > HTML/CSS Training > Free
Computer Training > Creating Links in Web Pages using HTML
Creating Links in Web Pages using HTML
Linking to another web page
<a href=“http://www…”>Click here</a> - this is called absolute addressing
http:// part has to be included for external links, otherwise it’s just the file you reference eg <a href=“filename.htm”>Click here</a>
Linking when using folders
If you are using folder to organise files then include the folder in the path to the file you are linking to:
<a href= “foldername/filename.htm”>Click here “</a>
- this is called relative addressing
Note the direction of the /
If you want to link back from this page to the main web folder you can use the following:
<a href= “../filename.htm”>Back</a>
Opening a link in another window
Use the target attribute of the anchor tag
<a href= “filename.htm” target= “_blank”>Click here</a>
Linking to specific part of a page
An Anchor is a named point on a web page: (often used for indexes)
<a id= “nameofanchor”></a> no text is necessary within the tags
To link to an anchor on the same page:
<a href= “#nameofanchor”>text</a>
To link to an anchor on another page:
<a href= “pagename.htm#nameofanchor”>text</a>
E-mail hyperlinks
<a href= “mailto:someone@somewhere.com”>E-mail me</a>
Subject and body attribute can be added. You separate the attributes from the e-mail address with a ? and the attributes themselves with a &.
<a href="mailto:someone@somewhere.com?
subject=The subject& body=The Body">E-mail me</a>
To thwart spammers use character entities in the place of characters in your e-mail address
The base tag
Appears in the <head> and specifies the base url against which all other links are mapped:
<base href= “http://www.yoursite.co.uk/” />
Please not all tags are HTML 5 compliant. HMTL 5 differences
|