HTML Links

z

Hyperlink


A hyperlink (often referred to as simply a link), is a reference or navigation element in a document to another section of the same document, another document, or a specified section of another document, that automatically brings the referred information to the user when the navigation element is selected by the user. As such it is similar to a citation in literature, but with the distinction of automatic instant access. Combined with a data network and suitable access protocol, a computer can be instructed to fetch the resource referenced.

Hyperlinks are part of the foundation of the World Wide Web created by Tim Berners-Lee, but are not limited to HTML or the web. Hyperlinks may be used in almost any electronic media.

HREF is an acronym for Hypertext REFerence, as used in HTML.

How hyperlinks work in HTML


A link has two ends, called anchors, and a direction. The link starts at the source anchor and points to the destination anchor. However, the term link is often used for the source anchor, while the destination anchor is called the link target.

The most common link target is a URL used in the World Wide Web. This can refer to a document, e.g. a webpage, or other resource, or to a position in a webpage. The latter is achieved by means of a HTML element with a "name" or "id" attribute at that position of the HTML document. The URL of the position is the URL of the webpage with "#attribute name" appended — this is a fragment identifier.

When linking to PDF documents from a HTML page the "attribute name" can be replaced with syntax that references a page number or another element of the PDF, for example page=[pageNo] - "#page=386".

Link behavior in web browsers


A web browser usually displays a hyperlink in some distinguishing way, e.g. in a different colour, font or style. The behaviour and style of links can be specified using the Cascading Style Sheets (CSS) language.

In a graphical user interface, the usage of a mouse cursor may also change into a hand motif to indicate a link. In most graphical web browsers, links are displayed in underlined blue text when not cached, but underlined purple text when cached. When the user activates the link (e.g. by clicking on it with the mouse) the browser will display the target of the link. If the target is not a HTML file, depending on the file type and on the browser and its plugins, another program may be activated to open the file.

The HTML code contains some or all of the five main characteristics of a link:
  • link destination ("href" pointing to a URL)

  • link label

  • link title

  • link target

  • link class or link id

It uses the HTML element "a" with the attribute "href" and optionally also the attributes "title", "target", and "class" or "id":

<a href="URL" title="link title" target="link target" class="link class">link label</a>

Example: To embed a link into a Page, blogpost, or comment, it may take this form:

<a href="http://htmloref.blogspot.com">HTML Online Reference</a>

Thus, the complex link string is reduced to, [HTML Online Reference]. This contributes to a clean, easy to read text or document.

When the cursor hovers over a link, depending on the browser and/or graphical user interface, some informative text about the link can be shown:

* It pops up, not in a regular window, but in a special hover box, which disappears when the cursor is moved away (sometimes it disappears anyway after a few seconds, and reappears when the cursor is moved away and back). IE and Mozilla Firefox show the title, Opera also shows the URL.

* In addition, the URL may be shown in the status bar.

Normally, a link will open in the current frame or window, but sites that use frames and multiple windows for navigation can add a special "target" attribute to specify where the link will be loaded. Windows can be named upon creation, and that identifier can be used to refer to it later in the browsing session. If no current window exists with that name, a new window will be created using the ID.

Creation of new windows is probably the most common use of the "target" attribute. In order to prevent accidental reuse of a window, the special window names "_blank" and "_new" are usually available, and will always cause a new window to be created. It is especially common to see this type of link when one large website links to an external page. The intention in that case is to ensure that the person browsing is aware that there is no endorsement of the site being linked to by the site that was linked from. However, the attribute is sometimes overused and can sometimes cause many windows to be created even while browsing a single site.

Another special page name is "_top", which causes any frames in the current window to be cleared away so that browsing can continue in the full window.

 

© New Blogger Templates | Webtalks