Make delicious recipes!

HyperLinks in HTML

A hyperlink has two parts:
  1. Text/image to be displayed
  2. URL pointed to by the hyperlink

Syntax for a hyperlink is:

<a href="URL pointed to"> Text/image to be displayed </a>

For example:

<a href="">

This is displayed as: PrismoSkills

The displayed content can be any HTML element.
For example, the above code can be changed to display an image instead of Google.

<a href="">
    <img src="PS2.PNG">

This is displayed as:

The above image is actually a hyperlink which can be clicked to navigate to another URL.

Special URLs

- points to the master domain name of current page.

- points to the current page's URL.

href="./<relative URL>"
- points to a URL relative to the current page.


<a href="/">Master domain</a>

<a href="">Current page's URL</a>

<a href="../CSS/Chapter_1_-_CSS_Introduction.jsp">Relative URL</a>

gives the following links:
Master domain
Current page's URL
Relative URL

Invoking Javascript

The URL for a link can be some javascript function also.
This can be done as:

function jsFunc()
    alert ("JS function called from hyperlink");
<a href = "javascript:jsFunc()">Example link for Javascript function</a>

Example link for Javascript function

Like us on Facebook to remain in touch
with the latest in technology and tutorials!

Got a thought to share or found a
bug in the code?
We'd love to hear from you:

Email: (Your email is not shared with anybody)

Facebook comments:

Site Owner: Sachin Goyal