HTML Hyperlinks (Links)
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 tag.
The <a> tag can be used in two ways:
|
HTML Link Syntax
The HTML code for a link is simple. It looks like this:
<a href=”url”>Link text</a>
LINK TARGETS
By default, links will open in the current window or frame.
You need to add target if you want the link to open in another window or frame than the link itself is placed in.
Predefined Target are:
|
The following example will open urimagination website in a new window:
More examples
Solution2me.net website (it will open in the same window) Solution2me.net website (it will open in a new window) Solution2me.net website (No Following Link)
HTML Links – The name Attribute
The name attribute specifies the name of an anchor.
The name attribute is used to create a bookmark inside an HTML document.
Note: The upcoming HTML5 standard suggests using the id attribute instead of the name attribute for specifying the name of an anchor. Using the id attribute actually works also for HTML4 in all modern browsers.
Bookmarks are not displayed in any special way. They are invisible to the reader.
Example
A named anchor inside an HTML document:
<a name=”tips”>Useful Tips Section</a>
Create a link to the “Useful Tips Section” inside the same document:
<a href=”#tips”>Visit the Useful Tips Section</a>
Or, create a link to the “Useful Tips Section” from another page:
<a href=”http://www.urimagnation.com/html_links.htm#tips”>
Visit the Useful Tips Section</a>
Basic Notes – Useful Tips
Note: Always add a trailing slash to subfolder references. If you link like this: href=”http://www.urimagnation.com/services”, you will generate two requests to the server, the server will first add a slash to the address, and then create a new request like this: href=”http://www.urimagnation.com/services/”.
Tip: Named anchors are often used to create “table of contents” at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.
Related Articles