The Use Of “A” Tag In HTML

Use Of “A” Tag

How Can The Use Of “A” Tags Be Beneficial In HTML?

The ‘a’ tag is basically used for adding links to the website.

Use Of “A” tag is essential in the HTML file/code when the need arises.

I’ve learnt about attributes…

Now, attributes are used for tags that are not self-closing… e.g, <a>, <img> etc.

The attribute for the ‘a’ tag is (href) then you input ‘url’ thereafter.

Types of html links

There are two types of link and they are:

  • Internal links
  • External links

Internal Links

Internal links are often used within the webpage i.e they do not exceed the page, in this case a target is being set within the internal page (in the HTML code)

We notice that in the image above there’s an “Id” above stating “up”, Yes! That’s the target.

The image above displays where the link would take us to in the HTML file.

External Links

The use of “a” tag can also be executed for external links in a rather straight forward way.

As the name implies, external links carries you away from the homepage to another page.

The image above validates it, I used the href attribute then I inserted the external link, afterwards, the attribute target was used, (target=“_blank”) is used to input the text to be displayed on our homepage in form of a link.

The result is shown above.

Leave a Comment

Your email address will not be published. Required fields are marked *