HTML <base> target Attribute

HTMLWeb DevelopmentFront End Technology

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 −


 Live Demo

<!DOCTYPE html>
<base href="" target="_blank">
<h2>Tutorials List</h2>

Java Tutorial

(This will act as

jQuery Tutorial

(This will act as

Blockchain Tutorial

(This will act as

Python Tutorial

(This will act as

</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="" target="_blank">

All the URLs will now open in anew window since we have set the target attribute for <base> element as −

Published on 20-Jun-2019 08:13:01