HTML Link

Link - <a> tag

<a> tag is used to link one web page to another web page.

In default, when you move the mouse pointer to the link(<a> tag) the mouse arrow will change to a little hand symbol.


Syntax

Example

Try Yourself

<a> tag target attribute

The target attribute specifies where to open the linked document.

This attribute can have the following values

_self value

This is the default value.

It is used to open the linked web page in the same window (It replaces the current working window).

Example

Try Yourself

_blank value

Used to open the linked web page in the new tab or window.

Example

Try Yourself

_parent value

Used to open the linked web page in the parent window.

In the following example we used iframe and Javascript code for understanding purpose only, so don't get confused about it.

Here we created an iframe to hold an another web page and it contains a link, so when you click that link the linked web page will be open in the parent window.

Instead of _parent, you can set the target attribute value as _self to see the difference between those two.

Example

Try Yourself

_top value

Used to open the linked web page as a new window replacing the current web page.

In the following example we used iframe and Javascript code for understanding purpose only, so don't confuse about it.

Here we created an iframe to hold an another web page and it contains a link, so when you click that link the linked web page will be open in the home window.

Instead of _top, you can set the target attribute value as _parent to see the difference between those.

Example

Try Yourself

_top value is used mostly on iframe, otherwise it works similar to _self, but they are not same.

iframe name attribute

Used to open the linked web page in the specified iframe.

In the below example, when you click the link the web page will be opened in the specified iframe.

Example

Try Yourself