HTML Links
Links, otherwise known as hyperlinks, are defined using the <*a> tag - otherwise known as the anchor element.
To create a hyperlink, you use the a tag in conjunction with the href attribute (*href stands for Hypertext Reference). The value of the href attribute is the URL, or, location of where the link is pointing to.
Example HTML Code:
This results in:
Visit the DK Dashing Blog
Hypertext references can use absolute URLS, relative URLs, or root relative URLs.
absolute This refers to a URL where the full path is provided. For example, http://dkdashinghtml1.blogspot.com/ relative This refers to a URL where only the path, relative to the current location, is provided. For example, if we want to reference the http://dkdashinghtml1.blogspot.com/ URL, and our current location is http://dkdashinghtml1.blogspot.com/, we would use tutorial/index.cfm
root relative.
This refers to a URL where only the path, relative to the domain's root, is provided. For example, if we want to reference the http://dkdashinghtml1.blogspot.com/ URL, and the current location is http://dkdashinghtml1.blogspot.com/, we would use /html/tutorial/index.cfm. The forward slash indicates the domain's root. This way, no matter where your file is located, you can always use this method to determine the path, even if you don't know what the domain name will eventually be.
A hyperlink (or link) is a word, group of words, or image that you can click on to jump to a new document or a new section within the current document.
When you move the cursor over a link in a Web page, the arrow will turn into a little hand.
Links are specified in HTML using the <*a> tag.
The <*a> tag can be used in two ways:
1. To create a link to another document, by using the href attribute
2. To create a bookmark inside a document, by using the name attribute
Link Targets
You can nominate whether to open the URL in a new window or the current window. You do this with the target attribute. For example, target="_blank" opens the URL in a new window.
The target attribute can have the following possible values:
_blank | Opens the URL in a new browser window. |
_self | Loads the URL in the current browser window. |
_parent | Loads the URL into the parent frame (still within the current browser window). This is only applicable when using frames. |
_top | Loads the URL in the current browser window, but cancelling out any frames. Therefore, if frames were being used, they aren't any longer. |
Named Anchors
You can make your links "jump" to other sections within the same page. You do this with named anchors.
To use named anchors, you need to create two pieces of code - one for the hyperlink (this is what the user will click on), and one for the named anchor (this is where they will end up).
This page uses a named anchor. I did this by performing the steps below:
1. I created the named anchor first (where the user will end up)
Example HTML Code: