Hello, and welcome to this unit of our HTML course series called HTML Links. HTML Links are used to link to web addresses or another part of your document.
The anchor tag <a></a> is used mainly to write links in HTML. For instance, if I want to write a link that people could click and land on facebook, This is how it would be written:
Now, let’s look at what the above code can be well explained:
Please note that you are supposed to put links in quotes (“”) and begin them with the protocol (http://) and have a trailing slash (/)after your address.
You can also link to a named anchor in the same document. For instance, I can have this code in the top of my html body:
<a name=”bottom”>Go to bottom</a>
… and this code in my footer part of the same document:
<a href=”#bottom”>Go to top</a>
Note the difference in the codes. When someone clicks on Go to bottom in the top of the page, this scrolls the page straight to the footer of your page where you have the last code. This is known as a Named Anchor or the Anchor Attribute.
The Target Attribute: You can set your links to open in another window in the same browser as people click it. This is done by adding a target (_blank)to the code right after address: with our code above, changing the code to
<a href=”http://www.facebook.com/” target=”_blank”>Facebook</a>
… would open the Facebook link in a new window
Email HTML Links
You can create an email link where visitors can click on and enable them send you email directly. This opens the default mail application on their device that would enable them send you an email. In this case, you need to place a mailto: followed by the email address to receive the message using the same link code:
<a href=”mailto:firstname.lastname@example.org”>Send us an email</a>
This ends our lesson in HTML Links. See you in our next lesson.