HTML anchor Tag

HTML Anchor Tag

The anchor tag or a Tag is an HTML tag which is used to create links on web page. It is also known as hyperlink. Anchor tag is used to link one page to another page. It is used to create hyperlinks to other web pages or websites or files. href attribute is used in anchor tag to define the links destination.

How to use Anchor Tag

To create a hyperlink the text is written between the starting anchor tag and ending anchor tag. The href attribute is used to define the destination of the link, the value of this href attribute is url address of the website, web page or a file. The syntax is shown below.

<!DOCTYPE html>
<html>
<body>
<a href="https://www.howtocodeschool.com/">HOW TO CODE SCHOOL</a>
</body>
</html>

The output of this html code would be like this.

HOW TO CODE SCHOOL

Browser support for Anchor Tag

Anchor tag is one of the primary html tags, it is also one of the most common and widely used tags. All present browsers like chrome, opera, firefox and internet explorer support this tag.

Default styling of Anchor Tag

The anchor tag is inline level element.

By default anchor tag would have three types of styling.

  1. The unvisited link is blue in color and underlined.

  2. The active link is red in color and underlined.

  3. The visited link is purple in color and also underlined.

Note: You can change these styles on anchor tag using simple css.

Attributes used in Anchor Tag

Following attributes are used in anchor tag. href is the most important attribute of anchor tag.

href attribute

href attribute is used in anchor tag. It defines the url of the link destination, it could be any page, website or file.

charset attribute

It is used for anchor tag. It defines the character encoding. It is not supported in HTML5.

coords attribute

It defines the coordinates of the link element or anchor tag. It is also not supported in HTML5.

download attribute

It is also used in anchor tag and it specifies that the file should be downloaded when the link is clicked.

hreflang attribute

It is used in anchor tag to define the language of the linked document.

media attribute

It is used for anchor tag to explain that which device is optimal for the linked web page or document.

name attribute

It defines the name of the anchor element. It is not supported in HTML5.

ping attribute

It specifies the list of urls. When the link is clicked the ping will be sent by the browser to these urls, it is used for tracking purposes.

referrerpolicy attribute

It is used in anchor tag to specify which referrer to send.

rel attribute

It is used for anchor tag. It defines the relationship of linked document or file with the current file or page.

rev attribute

It does the same thing what rel attribute does but it is not supported in HTML5.

shape attribute

It specifies the shape of link element or anchor tag, It is also not supported in HTML5.

target attribute

It is used in anchor tag to specify where to open the linked page or document. For example if it's value is set to "_blank" the page will always open in new tab whenever the link is clicked.

type attribute

It defines the media type of the linked document.

Global Attributes support in Anchor Tag

Anchor tag or a tag does support the Global Html attributes.

Event Attributes support in Anchor Tag

Anchor tag or a tag also supports the Event Html attributes.

HTML Anchor Tag Video

Watch our video on anchor tag and subscribe our Youtube Channel.

HTML anchor Tag HTML abbr Tag HTML acronym Tag HTML address Tag HTML applet Tag HTML area Tag HTML article Tag HTML aside Tag HTML audio Tag HTML b Tag HTML base Tag HTML basefont Tag HTML bdi Tag HTML bdo Tag HTML big Tag HTML blockquote Tag HTML body Tag HTML br Tag HTML Button Tag HTML Canvas Tag HTML Caption Tag HTML Center Tag HTML Cite Tag HTML Code Tag HTML Col Tag HTML colgroup Tag HTML comment Tag HTML data Tag HTML datalist Tag HTML dd Tag HTML del Tag HTML details Tag HTML dfn Tag HTML dialog Tag HTML dir Tag HTML div Tag HTML dl Tag HTML Doctype Tag HTML dt Tag HTML em Tag HTML embed Tag HTML fieldset Tag HTML figcaption Tag HTML figure Tag HTML font Tag HTML footer Tag HTML form Tag HTML frame Tag HTML frameset Tag HTML Heading Tags HTML head Tag HTML header Tag HTML hr Tag HTML html Tag HTML i Tag HTML iframe Tag HTML img Tag HTML input Tag HTML ins Tag HTML kbd Tag HTML label Tag HTML legend Tag HTML li Tag HTML link Tag HTML main Tag HTML map Tag HTML mark Tag HTML meta Tag HTML meter Tag HTML nav Tag HTML noframes Tag HTML noscript Tag HTML object Tag HTML ol Tag HTML optgroup Tag HTML option Tag HTML output Tag HTML p Tag HTML param Tag HTML picture Tag HTML pre Tag HTML progress Tag HTML q Tag HTML rp Tag HTML rt Tag HTML ruby Tag HTML s Tag