HTML HREF Attribute in Coding

href means


HREF is html link attribute that enable movement from one web page to another freely.

As websites are made up of multiple web pages, for movement from one page to another is possible only with href link attribute. Many web designers don't really know the full meaning of  'HREF link attribute' despite using it regularly.








In this guide, we'll treat the subheading listed below.

What Does Link 'HREF' Stand For?

How to Use Link HREF Attribute?

How to Use Link TARGET Attribute?

Without the 'href' html link attribute, no web app can achieve its purpose because there will be no movement within the app.

Imagine opening a web app and you are just stuck there, no next page, no previous page. This will be annoying and frustrated.

HREF stands for 'Hypertext Reference (H-Hypertext REF-Reference)'. Of course we all is aware what the word reference means. It means referencing to another file or page.


Website like w3schools will be of a good example. When you read tutorial on w3schools, getting to the end/bottom, you'll get to see 'NEXT' and 'PREVIOUS' referencing more information about what you're reading.


Note: also see these next and previous buttons on the top before you start read.


a href target blank

How to Use Link HREF Attribute?

Without the href link attribute, the link element is not complete and it is useless, because no action will occur even a user click on it.

For example, link element will look like this;
<a>Wrong</a>
The above code is useless because the link does not have 'href attribute', and contain no reference file name with.

For example, link element will look something like this;
<a href='superguideblog.com'>correct</a>

Note: In the above correct link element, the href contains the URL of this blog as the file name. It can be any file available on the host root.

Some examples below;

<a href='about-us.html'>correct</a>

<a href='home.html'>correct</a>








How to Use Link TARGET Attribute?

The link target attribute is not compulsory, but very important in some cases depending on the developer's choice.

In many websites, we have come across this function without knowing why it is happening. Websites that set their link 'target attribute' to blank will enable you to open links in a new browser tab.


Code example; <a target='blank'>open this link in new tab</a>

Code example; <a href='home.html' target='blank'>open this link in new tab</a>

Code example; <a href='sport.html' target=''>open this link in same browser tab</a>


href stands for

 

 

TEST TIME

What is wrong with the codes below?

Test Code; <a href=superguideblog.com' target='blank'>Wrong</a>

Test Code; <a href='enertainment.html' target='' >Wrong</>

Drop the correct codes in the comment box.

Comments

  1. This article really helped me to understand what really is href. Thanks Jerry for sharing.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Delete Record From Table Using PHP MySQL

Guide to add blog URL to Google search console

Best steps to master JavaScript programming language