Forum Moderators: open
a[target="_blank"]{background:red;}
This uses the attribute selector [w3.org], which is not supported by IE browsers, so it doesn't work there, but in FF and O it works like a charm. If you use the WebDev toolbar in FF, just save the code to a css file on your computer, click the "Add User Stylesheet" option in the CSS button, browse to the stylesheet and select it. If you want it to apply that CSS as you surf around, go to Options and check "Persist Styles."
In Opera it's Tools>Preferences>Advanced Tab>Content>Style Options...browse to the CSS file and then enable it by checking the "My Stylesheet" checkbox under which ever profile you're using.
If, instead, you're looking for a way to visually cue all visitors to your site that a link will open in a new window, you could use the above code, but IE users wouldn't get it. A more labor intensive, but cross-browser, way would be to mark outbound anchor tags with a special classname and apply styling to that...
html:
<a href="#" class="outbound" target="_blank">Link</a>css:
.outbound{background:url(images/outbound_icon.gif) left no-repeat;padding-left:15px;}
cEM
It would be cool if it became trendy for webmasters to apply the second stylesheet on their sites, because even applying it on your site(s), a new user won't know what it is unless you explained it and they happened to pass by that explanation page on your site.
a { color: expression(this.target=="_blank"? '#900' : '#000'); }
For more details see this thread [webmasterworld.com], or this one [webmasterworld.com].
-B
I'm going to try to make the most sense here and cover the standard targets in a logical way and then ask you how to add "all other" targets at the bottom of this.
Two questions first.
1. Does anyone have experience with the _parent target? How does it work exactly?
2. Isn't "_new" the same thing as _blank? I just looked it up and don't see _new listed so maybe my memory fails? Anyway, the code below assumes it's the same.
a[target="_blank"]{
background:red;
}
a[target="_new"]{
background:red;
}
a[target="_top"]{
background:blue;
}
a[target="_self"]{
background:blue;
}
a[target="_parent"]{
background:purple;
}
a[target="XXXXXXX_for_other?_XXXXXX"]{
background:green;
}