Saturday, July 9, 2022

HTML Tag a


HTML  <a>  Tag

Example

Create a link to W3Schools.com:

<a href="https://www.w3schools.com">Visit W3Schools.com!</a>
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The <a> tag defines a hyperlink, which is used to link from one page to another.

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

By default, links will appear as follows in all browsers:

  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red

Tips and Notes

Tip: If the <a> tag has no href attribute, it is only a placeholder for a hyperlink.

Tip: A linked page is normally displayed in the current browser window, unless you specify another target.

Tip: Use CSS to style links: CSS Links and CSS Buttons.

Global Attributes

The <a> tag also supports the Global Attributes in HTML.


Event Attributes

The <a> tag also supports the Event Attributes in HTML.

More Examples

Example

How to use an image as a link:

<a href="https://www.w3schools.com">
<img border="0" alt="W3Schools" src="logo_w3s.gif" width="100" height="100">
</a>
Try it Yourself »

Example

How to open a link in a new browser window:

<a href="https://www.w3schools.com" target="_blank">Visit W3Schools.com!</a>
Try it Yourself »

Example

How to link to an email address:

<a href="mailto:someone@example.com">Send email</a>
Try it Yourself »

Example

How to link to a phone number:

<a href="tel:+4733378901">+47 333 78 901</a>
Try it Yourself »

Example

How to link to another section on the same page:

<a href="#section2">Go to Section 2</a>
Try it Yourself »

Example

How to link to a JavaScript:

<a href="javascript:alert('Hello World!');">Execute JavaScript</a>
Try it Yourself »

Related Pages

HTML tutorial: HTML Links

HTML DOM reference: Anchor Object

CSS Tutorial: Styling Links


Default CSS Settings

Most browsers will display the <a> element with the following default values:

a:link, a:visited {
  color: (internal value);
  text-decoration: underline;
  cursor: auto;
}

a:link:active, a:visited:active {
  color: (internal value);
} 

SHARE THIS

Author:

urdufundastory.blogspot.com is the first of its kind of trendsetting venture existent in Pakistan. It is for the first time in the history of this nation that a large scale project of such nature, evolved from an extraordinarily revolutionizing concept to a practical fulfillment.

0 Comments: