- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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"