
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML target Attribute
The target attribute of the <a> element is used to set where the linked document will open. You can set the document to open in a new window, same frame, parent frame, etc.
Following is the syntax −
<a target="_blank|_self|_parent|_top| frame">
Here, _blank is used to open the linked document in new window or tab, _self opens the linked document in the same frame as it was clicked, _parent opens the document in the parent frame, _top opens the linked document in the entire body of the window, frame opens the linked document in a named frame.
Let us now see an example to implement target attribute in <a> element −
Example
<!DOCTYPE html> <html> <body> <h2>Learning is Fun</h2> <p><strong>Note −</strong> The links will open in new window.</p> <p><a href="https −//www.tutorialspoint.com/tutorialslibrary.htm" target="_blank">Tutorials Library</a><br> <a href="https −//www.tutorialspoint.com/programming_examples/" target="_blank">Codes</a><br> <a href="https −//www.tutorialspoint.com/computer_glossary.htm" target="_blank">Computer Glossary</a> <br> </body> </html>
This will produce the following output. The below links will open in new window −
In the above example, we have set the target in the target attribute −
<a href="https −//www.tutorialspoint.com/tutorialslibrary.htm" target="_blank"> Tutorials Library </a>
The attribute set above has value _blank, which opens the link in the href attribute in a new window −
target="_blank"
- Related Articles
- HTML target Attribute
- HTML target Attribute
- HTML target Attribute
- Target a Window Using JavaScript or HTML
- HTML DOM Anchor target Property
- HTML DOM Base target Property
- HTML DOM Form target property
- HTML pattern Attribute
- HTML novalidate Attribute
- HTML maxlength Attribute
- HTML wrap Attribute
- HTML disabled Attribute
- HTML for Attribute
- HTML min Attribute
- HTML disabled Attribute
