Description
Anchor tag which is seen as <a> is used to create a hyperlink on the html page. It links one page to another page.
href attribute of <a> tag is used to define the the destination link for the hyperlink as shown below in the example.
<a href="https://thegyanva.com/publication/mister_coder">click here</a>
Output : click here
The above link will load the new page in the same window.
Here comes new attribute which is used to open the destination page in the new window, that is target, we need to set the target as _blank
<a href="https://thegyanva.com/publication/mister_coder" target="_blank">click here</a>
Output : click here
In order to call the JavaScript function instead of redirection we can use the onclick attribute instead of href as shown below in the example.
<a onclick="alert('hello')">click here</a>
Output : click here
Note : removing href attribute will impact the css properties and you might see a difference in color/design properties.
Attributes
href | Url of the destination page |
media | media or device linked document |
ping | space separated list of URLs of previous links |
target | location for opening the page (_blank, _parent, _self, _top) |