Anchor Tags


Anchor Tags in HTML are used to link the content on your site to another page on your website, an external website, or even to access a user's email locally. In the example boxes below, you can see their usage in all the contexts mentioned above. All anchor tags have the format of <a href=""></a>. In between the quotations of the href, which stands for hypertext reference, you input the link you would like to reference to. Between the angled brackets of the 'a' tag, you include text referring to the hyperlink you linked in the href. You can also add more arguments to the anchor tag. For example, you can add target="_blank" after a link to another broswer so that when you click that link, that link opens a new tab in your browser, as opposed to loading on top of the page you were just on. (Take a look at the difference in your tabs when you open the Google and Homepage link)



Anchor tag referring to an external link from the browser:



Code:


<a href="https://www.google.com/?client=safari">Link to Google</a>

Output:


Link to Google


Anchor tag referring to an internal link in the browser:



Code:


<a href="/index.html" target="_blank">Link to Homepage</a>

Output:


Link to Homepage


Anchor tag referring to an email that is accessing a user's email:



Code:


<a href="mailto:youremail@gmail.com">Link to your email</a>

Output:


Link to your email