The <a> tag is a hyperlink, which is used to link one page to another.It uses with many attributes but **href** is most important attribute that have destination of linked page. The general attributes use with <a> tag are:- download, hreflang, media, rel, target,title and type.
***These attributes are not useful without href.***

e.g.
<a href="http://watchtvlive.in">watchtvlive</a>
when you click on "watchtvlive" the destination page of that web address will be load or open on parent page or new tab.



href Attribute

The href attribute specifies the URL of the linked page.
***withhout the href attribute, the <a> tag is not a hyperlink.***

how to add href in <a> tag:-

e.g.
<a href="http://watchtvlive.in">Livetv</a>

it will look like when you add in paragraph:-
<a href="watchtvlive.in">watchtvlive</a> is a live tv website. =watchtvlive is a live tv website.

<a href="add here your web address which you want to linked with this page or when user click on this link user go to that page">you can write anything here</a>
 


So we can say that it as main attribute of <a> tag and another attributes are sub attributes that used with href attribute.
Another use of href attribute:-
  • go to top
<a href="#top">Go to top</a>  

When a user goes bottom of page,again use scroll bar to get on up,so by using this attribute when user click on link,user get on up without using scroll bar.


  • Link to an email address with a specified subject:

<a href="mailto:somebody@example.com?Subject=write here subject">Send mail!</a> when you have installed mail,then if you click on this mail link mail will automatically send to whose you want to mail.


  • Link to multiple email addresses with a specified subject and a specified message:

<a href="mailto:somebody@example.com?cc=someoneelse@example.com&bcc=andsomeoneelse@example.com &subject=write here subject&body=write here message">Send mail!</a>


  • Link to a JavaScript:

<a href="javascript:alert('Hello webschool!');">Execute JavaScript</a>



Sub Attributes


  • Tittle Attribution
<a href="http://watchtvlive.in" title="watchlivetv">live tv</a> When cursor go on link text **live tv** it show **watchtvlive** It can use when you want to show brief specification of destination page.

  • Download Attribute
The download attribute specifies that the target will be downloaded instead of open in new page or loading in same page when a user clicks on the link. The download tag is a HTML5 attribute. <a href="/image.jpg" download="watchtvlive"></a>


  • Target Attribute
This attribute specifies that your destination page will load in parent page(or same page) or open in new tab. e.g.<br/> <a href="http://www.watchtvlive.in.com" target="_blank">watchtvlive</a> values for this attribute Value Description _blank Opens the linked page in a new window or tab _self Opens the linked page in the same frame that is default _parent Opens the linked page in the parent frame _top Opens the linked page in the full body of the window -framename Opens the linked document in a named frame
****e.g. <a href="http://www.watchtvlive.in.com" target="_blank">watchtvlive</a> in the tag line target is attribute while ***_blank is it's value.****


  • hreflang Attribute
this attribute specifies the language of the linked document. It is also a sub attribute for <a> tag. we can add it just like:- <a href="http://www.w3schools.com" hreflang="en">W3Schools</a>
e.g. of 2 letter codes english-en,hindi-hi,Arabic-ar

2 comments: