Anchor tag (<a>
tag) in HTML is used to create a link between the pages or documents. The most common use of anchor tag is, to link between the web pages or sections in the page to navigate between them.
The most common attribute we use is href
attribute; to create hyperlinks to web pages. Here something looks like below; created a hyperlink to our website.
<a href="https://www.codesteps.com/">CodeSteps</a>
When a user clicks on the hyperlink, it takes to the mentioned destination. From above, it opens the link in the current window. It provides the option to select where to open the specified URL (mentioned in href
) through its’ target
attribute.
When we specify “_self
” as target
attribute’s value for anchor tag (<a>
tag); the hyperlink will open in the current window. To open the hyperlink in a new tab or window, we can specify “_blank
” as the value for the target
attribute. Below code will open the hyperlink in either a new tab or window;
<a href="https://www.codesteps.com/" target="_blank">CodeSteps</a>
By default, the hyperlink will open in the current window unless we specify the specific target through its’ traget
attribute.
**