Hyperlinks in HTML:
Links allow you to jump from one page to another by clicking on the link text. You can also jump to places on the same page (called fragments), to different sections of your site, or to another web site all together.
A link is specified using the <a> element. This element is called anchor tag as well. Anything between the opening
<a> tag and the closing </a> tag becomes part of the link and a user can click that part to reach to the linked document.
Following is the simple syntax to use this tag.
<a href="/Document URL" attr_name="attr_value"...more attributes />
You May Also Like:
Features of HTML
Structure of HTML Document
HTML Formatting Tags
Different Types of Lists in HTML
Anchor Attributes:
Following are most frequently used attributes for <a> tag.
href: Specifies the URL of the target of a hyperlink. Its value is any valid document URL, absolute or relative, including a fragment identifier or a JavaScript code fragment.
target: Specify where to display the contents of a selected hyperlink. If set to "_blank" then a new window will be opened to display the loaded page, if set to "_top" or "_parent" then same window will be used to display the loaded document, if set to "_self" then loads the new page in current window. By default its "_self".
name & id: Attributes places a label within a document. When that label is used in a link to that document, it is the equivalent of telling the browser to goto that label.
event: Attributes like onClick, onMouseOver etc. are used to trigger any Javascript or VBscript code.
title: Attribute lets you specify a title for the document to which you are linking. The value of the attribute is any string, enclosed in quotation marks. The browser might use it when displaying the link, perhaps flashing the title when the mouse passes over the link.
There are 3 categories of links
1. Internal:
The internal links are used to link to the other places on the same web page, such as other sections or chapters further down the page. The technical term for this is linking to a Fragment, where browsers will automatically try and scroll to that part of the page. Fragments first need to be defined somewhere in a web page by giving them a name,
for example <a name="fragment_name">, then links to this fragment are created by using the hash (#) character: <a href="#fragment_name">Link</a>.
Example:
<html>
<head>
<title> Internal Links </title>
</head>
<body>
<p> chapter 1: Basic HTML,The document body, Text, Hyper links adding more formatting lists, tables, columns and images.</p>
<p>chapter 2: More HTML multimedia objects, frames, forms, the HTML document head in details, xHTML-an Evaluationary markup. </p>
<a name=’chapter 3”></a>
<p>chapter 3: Cascading Style Sheets: Introduction, Using styles:simple examples, defining your own styles, properties and values in styles, style sheets -a worked example, formatting blocks of information, layers.</p>
<p>chapter 4: An Introduction to Java Script: What is dynamic HTML,Java script,the basics of java script, variables, string manipulation, mathematical, functions, statements, operators, arrays and functions.
</p>
<p>chapter 5: Objects in Java Script:Data and objects in java script,regular expressions, exception handling, built in objects, events.
<a href=”#chapter 3”>click here for chapter 3</a> </p>
</body>
</html>
2. Local links:
This type of links is used to link other pages within the current Website.
<html>
<head>
<title> Main Page </title>
</head>
<body>
<p>
Hello World <a href=”second.html”>click here for second page</a>
</p>
</body>
</html>
3. Global:
This type of links is used to link other pages outside of the current site.
<html>
<head>
<title> Global Links </title>
</head>
<body>
<p>
Link other pages outside of the current site.
<a href=”http://www.google.com”>click here for google</a>
</p>
</body>
</html>
You May Also Like:
Tables in HTML
HTML Css(Cascading Style Sheets)
Forms in HTML
Different CSS Properties