Three WWW terms are defined as follows:
- Links
- A link is the “address” to a document (or a resource) on the Web.
- Hyperlinks
- A hyperlink is a reference (an address) to a resource on the Web.
Hyperlinks can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc.
- Anchors
- An anchor is a term used to define a hyperlink destination inside a document.
The HTML anchor element
<a>
, is used to define both hyperlinks and anchors.
An HTML Link
Link syntax is as follows:
<a href="url">Link text</a>
The start tag contains attributes about the link.
The element content (link text) defines the part to be displayed.
The element content does not have to be text.
You can link from an image or any other HTML element.
The href Attribute
The href
attribute defines the link “address” such as W3C as below.
It will display like this in a browser: Visit W3C!
<a href="http://www.w3c.org/">Visit W3C!</a>
The target Attribute
The target
attribute defines where the linked document will be opened.
The code below will open the document in a new browser window:
<a href="http://www.w3c.org/" target="_blank">Visit W3C!</a>
Demonstration
The following demonstration shows how the HTML script is displayed on the Web.