# Anchor Tag

## What is an Anchor Tag?

An anchor tag is an HTML tag. It is used to define the beginning and end of a hypertext link. It contains visible words within a text that can be clicked and the URL of the link's target. Search engines use this HTML tag in order to determine the subject matter of the linked target.

## How to build a Hyperlink with an Anchor Tag

<a href="http://www.beispiel.com">My sample page </a>


An Anchor tag is defined with '<a>' and consists of three parts:

## href attribute

To create a hyperlink, the destination (address) of the document must be known. A hyperlink can link to pages on your own domain, to other websites, or to a file (such as a PDF document).

If you want to link to the Google homepage, the code looks as follows from:

<a href="http://www.google.com">Google Home</a>


Href is short for hypertext reference. This attribute defines the target address of the document, which is to be linked to (http://www.google.com). The “=” sign is the connection of the attribute with the attribute value, whereby “href” is the attribute and “ http://www.google.com ” is the attribute value. There is an apostrophe before and after the attribute value. The defined phrase “Google Home” is called anchor text or link text. This part is clickable in the text. An anchor text is ideally informative and relevant to the landing page.

If you want to link internally to another part of your website, you don’t have to specify the full address, the filename is sufficient:

<a href="MyPage.html">My page</a>


## Name attribute

The name attribute of the anchor tag can be used to enable users to “jump” to a specific point on a page (jump marker, anchor). This is especially useful with large pages or subdivisions.

The HTML code looks like this:

<a name="to top"></a> or
<a name="Content">Content</a>


In the first code sample, you link from the bottom of a page back to the beginning. So users can quickly get to the top of that page without having to scroll for a long time. In the second example, users can get direct access to the page, for example, by linking to a subdivision point. By clicking, users are guided via name attribute directly to the subject.

<a href="#Content">Content</a>


By simply setting a hash tag (#) at the anchor name the browser can identify a jump within the page.

You can also link to a specific location on another page internally and that would be defined as follows:

<a href="anotherpage.html#name">Linktext</a>


The “#name” is specified after the filename.

## Target attribute

The target attribute specifies how the destination page or the target document should be opened. “target=” _ blank “ is used for opening of the target page in a new window. This is the usual option when using target attributes for linking to other pages.

<a href="http://www.mypage.com" target="_blank">Linktext</a>


## Title attribute

The title attribute gives users an important clue as to where he will be directed to, if he clicks a link. If the user hovers with the mouse over a link reference, the title text, which was defined in the attribute, will be displayed. This can be a tool tip or the description of the resource to which the link directs. The data from the title attribute makes the site more user-friendly. becomes the <a href="schokoladenkenner.html" title="100 ways to prepare chocolate">preparation</a> of chocolate

The title attribute can also be used for images and graphic files in order to give a brief description of what is shown in the picture.

<img src="beispielbild.png" al ="sample image" title ="Here you can see a sample image">


## Importance for search engine optimization

The “preparation” string in the upper HTML reference is the link text that is visible in the body text of a website and may appear as blue text or underlined, depending on the layout. Link text is also called anchor text and is particularly important from the perspective of search engine optimization. The anchor text is part of the anchor tag.

Anchor tags are an essential tool for optimizing HTML documents for search engines. Anchor text and title attributes are used to give users and search engines more information. As with the naming of URLs, carefully researching keywording is also essential with anchor text for internal linking, because keywords placed there can benefit users and ranking.