I'm making a webpage with a lot of links, which should all open in a new tab using target="_blank"
.
Is it possible to apply this to all <a>
tags by default, so I can spare the time by not inserting it a every link?
You can make a HTML link open in a new tab by adding the target=”_blank” attribute. You should insert this after the link address.
To open a link in a new browser window, hold the Shift on then click the link or right-click the link and select Open link in New Window.
Well, there is a native HTML tag to handle such cases automatically. You don't need to manually add target="_blank" in all the tag. Just add target="_blank" in the base tag, it will open in a new tab for all the link present in the webpage.
Yes - you can specify a base target in the page's head:
<head>
<base target="_blank">
</head>
Source.
If you need to override this for a particular link so that it doesn't open in a new window, you can do this manually by setting that link's target
to "_self"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With