DEV Community

Jyotishman Saikia
Jyotishman Saikia

Posted on

HTML Tip: Automatically open all links in new tab in HTML

Did you get tired of manually adding target="_blank" in all the tags in your HTML webpage?
or
Have you ever forgotten to add target="_blank" in all the tags in your HTML webpage?

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.

I post very frequently on twitter related to frontend tips.
Support my content by following on
Twitter - https://twitter.com/frontend_jsx
Instagram - https://www.instagram.com/frontend.jsx/

Top comments (4)

Collapse
 
payapula profile image
payapula

Nice one! Can we override the '_blank' in anchor tags with this in place?

Collapse
 
jyotishman profile image
Jyotishman Saikia

hey payapula ! I didn't get what you said.

Collapse
 
aarone4 profile image
Aaron Reese

I think he means, if you set _blank as default, can you still override for a specific link.

Thread Thread
 
jyotishman profile image
Jyotishman Saikia

Hey Aaron ! Didn't tried that. But i guess we can do that