"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Can CSS Open Links in New Tabs Like \"target=_blank\"?

Can CSS Open Links in New Tabs Like \"target=_blank\"?

Posted on 2025-03-23
Browse:499

Can CSS Open Links in New Tabs Like \

Using CSS to Add "target=_blank" to External Links

Opening external links in new tabs is a common usability feature. While HTML provides the "target=_blank" attribute to achieve this, you may wonder if there's a similar CSS property.

Is there a CSS alternative to "target=_blank"?

Unfortunately, no, there is not a pure CSS solution to open links in new tabs. CSS does not have the ability to influence link behavior.

HTML Solution

Instead of relying on CSS, you can use the following HTML code in the

tag:

    

This sets all links on the page that do not specify a target attribute to open in a new window or tab.

Overriding "target=_blank" with Links

If you need specific links to override the default, you can use the "target=_blank" attribute on individual links:

test-link

This will override the general "target=_blank" setting defined in the

tag for that particular link.
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3