Add target="_blank" in CSS

Ali picture Ali · Jun 24, 2013 · Viewed 138.5k times · Source

I have external links in top menu of my website. I want to open these links in new tab. I could achieve it using "target=_blank" in HTML. Is there a similar CSS property or anything else?

Answer

Mojtaba Rezaeian picture Mojtaba Rezaeian · Jan 11, 2014

As c69 mentioned there is no way to do it with pure CSS.

but you can use HTML instead:

use

<head>
    <base target="_blank">
</head>

in your HTML <head> tag for making all of page links which not include target attribute to be opened in a new blank window by default. otherwise you can set target attribute for each link like this:

    <a href="/yourlink.html" target="_blank">test-link</a>

and it will override

<head>
    <base target="_blank">
</head>

tag if it was defined previously.