HTML <a>
query_builder | Christopher PisaniTo create a link in a page we use the tag <a>. This is called a hyperlink. It is usually used to move to another page, but it also can be used to move to an ID on the same page, to open an email client, call on a contact number.
Moving to another page :
<!--
href - The link you want to direct the page to
target - Opens the link in another page [opens in same page if ' target ' attribute is not used]
-->
<a href="https://www.jazzo.co.uk" target="__blank">
Jazzo Home Page
</a>
Moving to an ID :
<!-- This example will show you how the move to ID works -->
<a href="#test">
Click here to move to ID 'test'
</a>
<br/>1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/>10
<br/>11<br/>12<br/>13<br/>14<br/>15<br/>16<br/>17<br/>18<br/>19<br/>20
<br/>21<br/>22<br/>23<br/>24<br/>25<br/>26<br/>27<br/>28<br/>29<br/>30
<div id="test">
Hello World
</div>
Email and phone number example :
<!-- Click on email to test (fake email address) -->
<a href="mailto:info@example.com">
info@example.com
</a>
<br/>
<!-- Click on number to test (fake contact number)-->
<a href="tel:+445552999888">
(44) 555-2999-888
</a>
Available Attributes
Attribute | Values | Functionality |
---|---|---|
href | url | Specifies the link |
target | _blank _parent _self _top |
Specifies were to open the link |
ping | url | Sends an HTTP POST to a specified URL, generally used for tracking or count clicks on a particular link. |
rel | alternate author bookmark external help license next nofollow noreferrer noopener prev search tag |
The relationship between the current document and the document you are about to open |
media | format | Gives info about media type the document will compose of |
hreflang | url | The language of the linked document |
type | format | The media of the linked document |