A link is a connection from one Web resource to another
A D V E R T I S E M E N T
A link has two ends(anchors) and a direction.
The link starts at the "source" anchor and points to the "destination" anchor,
which may be any Web resource (e.g., an image, a video clip,
a sound bite, a program, an HTML document, an element within an HTML document, etc.).
The Anchor Tag and the Href Attribute
HTML uses the anchor (<a>) tag to create a link to another document.
An anchor can point to any resource on the Web:
an HTML page, an image, a sound file, a movie, etc.
The syntax of creating an anchor:
<a href="url">Text to be displayed</a>
The <a> tag is used to create an anchor to link from,
the href attribute is used to address the document to link to,
and the words between the open and close of the anchor tag will be displayed as a hyperlink.
The Anchor Tag and the Name Attribute
The name attribute is used to create a named anchor.
We can create links that can jump directly into a specific section on a page, using named anchors
instead of letting the user scroll around to find what he/she is looking for.
Below is the syntax of a named anchor:
<a name="label">Text to be displayed</a>
To create a named anchor the name attribute is used. The name of the anchor can be any text you care to use.
The line below defines a named anchor:
<a name="main">Main Section</a>
You should notice that a named anchor is not displayed in a special way.
To link directly to the a section, add a # sign and the name of the anchor to the end of a URL, like this:
<a href="http://www.testsworld.com/HTML_links.asp#main">
Jump to the Main Section</a>
A hyperlink to the Main Section from within the file "HTML_links.asp" will look like this:
<a href="#main">Jump to the Main Section</a>
The Target Attribute
With the target attribute, you can define where the linked document will be opened.
The line below will open the document in a new browser window: