The a trong html w3schools


Example

Create a link to W3Schools.com:

Visit W3Schools.com!

Try it Yourself »

More "Try it Yourself" examples below.

Definition and Usage

The

Try it Yourself »

Example

How to open a link in a new browser window:

Visit W3Schools.com!

Try it Yourself »

Example

How to link to an email address:

Send email

Try it Yourself »

Example

How to link to a phone number:

+47 333 78 901

Try it Yourself »

Example

How to link to another section on the same page:

Go to Section 2

Try it Yourself »

Example

How to link to a JavaScript:

Execute JavaScript

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 Visit W3Schools

Try it Yourself »

More "Try it Yourself" examples below.

Definition and Usage

The href attribute specifies the URL of the page the link goes to.

If the href attribute is not present, the or href="#" to link to the top of the current page!

Browser Support

Attribute
href Yes Yes Yes Yes Yes

Syntax

Attribute Values

ValueDescription
URL The URL of the link.

Possible values:

  • An absolute URL - points to another web site [like href="//www.example.com/default.htm"]
  • A relative URL - points to a file within a web site [like href="default.htm"]
  • Link to an element with a specified id within the page [like href="#section2"]
  • Other protocols [like //, ftp://, mailto:, file:, etc..]
  • A script [like href="javascript:alert['Hello'];"]

More Examples

Example

How to use an image as a link:



Try it Yourself »

Example

How to link to an email address:

Send email

Try it Yourself »

Example

How to link to a phone number:

+47 333 78 901

Try it Yourself »

Example

How to link to another section on the same page:

Go to Section 2

Try it Yourself »

Example

How to link to a JavaScript:

Execute JavaScript

Try it Yourself »

❮ HTML tag


Chủ Đề