How to use the target attribute in the <a> Tag in HTML ?
Last Updated :
24 Jan, 2024
The target
Attribute in the <a>
Tag is used to specify where the linked document should be displayed when the user clicks on the hyperlink. It controls the behavior of the link, determining whether the linked content should open in the same browser window, a new browser window, or a new tab. The target
attribute accepts different values that define the target location.
Syntax
<a href="https://www.geeksforgeeks.com" target="_blank">
GeeksforGeeks
</a>
Attribute Values
Here are common values for the target
attribute:
- _blank: Opens the linked document in a new browser window or tab.
- _self: Default behavior. Opens the linked document in the same window or tab.
- _parent: Opens the linked document in the parent frame.
- _top: Opens the linked document in the full body of the window.
Example: Implementation of the target attribute in HTML.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport"
content = "width=device-width, initial-scale=1.0" >
< title >Numbering</ title >
</ head >
< body >
target = "_blank" >GeeksforGeeks
</ a >
</ body >
</ html >
|
Output:
Share your thoughts in the comments
Please Login to comment...