What is the anchor tag?

The HTML Anchor tag is used to create hyperlinks to other webpages, emails, applications, and items.

Note: By default, unvisited links will appear blue, visited links will appear purple, and active links will appear red.

svg viewer

The following codes show working examples for each code.

Opening a webpage in a new window

Note: By default, the link opens in the same browser unless a target is specified.

Here is an example:

Linking an email

The anchor tag allows users to send emails from their outlook installed on their computers directly.

Here is an example that shows how email code can be added:

Adding a JavaScript

The anchor tag allows users to run JavaScript by clicking on them.

Here is an example:

Linking a phone number

The anchor tag allows users to call others from their phones directly.

Here is an example:

Attributes

You can add the following attributes to your anchor tag. Each is specifically designed to carry out a particular task.

AttributedownloadmediahrefhreflangpingtypetargetrelValuefilenamemedia_queryURLlanguage_codelist of URLSmedia_type_blank /_parent /_self /_topDescriptionDownloads the fileSpecifies the media device the document will work onSpecifies the URL of the page.Specifies the language of the docPing requests are sent to the Space seperated list in backgroundSpecifies the media type of linkSpecifies where to open the link

Other attributes, such as rel, show the relationship between documents and the referrer policyspecifies which referrer to send, but these are rarely used.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved