- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 <base> element is used to set the default target for the hyperlinks in a document.
Following is the syntax −
<base 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 the target attribute of the <base> element −
Example
<!DOCTYPE html> <html> <head> <base href="https://www.example.com/tutorials/" target="_blank"> </head> <body> <h2>Tutorials List</h2>(This will act as https://www.example.com/tutorials/java.html)
(This will act as https://www.example.com/tutorials/jquery.html)
(This will act as https://www.example.com/tutorials/blockchain.html)
(This will act as https://www.example.com/tutorials/python.html)
</body> </html>
This will produce the following output. When you will click on any of the below link, it will open in a new window since it is set _blank −
Above, we have set the base URL −
<base href="https://www.example.com/tutorials/" target="_blank">
All the URLs will now open in anew window since we have set the target attribute for <base> element as −
target="_blank"
- Related Articles
- HTML DOM Anchor target Property
- HTML DOM Base target Property
- HTML DOM Form target property
- HTML checked Attribute
- HTML datetime Attribute
- HTML value Attribute
- HTML coords Attribute
- HTML hreflang Attribute
- HTML cite Attribute
- HTML cite Attribute
- HTML autocomplete Attribute
- HTML max Attribute
