Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

styling a target

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
Is it possible to put a target (ie <a href="#" target="_blank">) into a style sheet?

[conehead]
 
I don't think it is possible. Why? What are you trying to accomplish by doing this?

"Ships that pass in the night and speak each other in passing;
Only a signal shown and a distant voice in the darkness;
So on the ocean of life we pass and speak one another,
Only a look and a voice; then darkness again and a silence."
- Henry Wadsworth Longfellow
 
I have this set of links that all need to do target="_blank"... just wondering if it was possible... thanks...

[conehead]
 
Give the links with target="_blank" a class and define that class with presentational items using CSS. Confused yet? Like this:

Code:
.fooboo {
your-stuff:here;
}

......................................

<a href="your.link" class="fooboo" target="_blank">...

"Ships that pass in the night and speak each other in passing;
Only a signal shown and a distant voice in the darkness;
So on the ocean of life we pass and speak one another,
Only a look and a voice; then darkness again and a silence."
- Henry Wadsworth Longfellow
 
yeah - that's what I did... what I was wanting to know was if I could get target="_blank" into the class (.fooboo).... maybe I am misunderstanding what you are saying (a likely scenario)

[conehead]
 
I don't think you can put attributes into a stylesheet. I think you can only use tags, IDs and CLASSes.

The other option is to use a scripting language. Client-side JavaScript will do it. I don't know about VBScript, ASP, PHP, or any other scripting languages.

Hope that helps!

"Ships that pass in the night and speak each other in passing;
Only a signal shown and a distant voice in the darkness;
So on the ocean of life we pass and speak one another,
Only a look and a voice; then darkness again and a silence."
- Henry Wadsworth Longfellow
 
There is a difference between form and function - CSS is only the form part of HTML. It changes the way the information is presented, but it cannot change the function or the what happens to the information (including links).

I had a friend try to do the same thing making a text input box readonly using CSS. It is not possible. There are somethings that HTML must do.

Einstein47
(Sometimes you're the windshield... sometimes you're the bug - Unknown)
 
If you really want to achieve this using CSS, then consider looking into behaviours (although you'll have to search on the American spelling, "behaviors"). This will let you attach scripts to items that match CSS selectors.

Currently they work in IE and Mozilla, although I believe you have to write different code for each browser. They've been supported in IE since v5, pretty much.

Check out for some examples of what behaviours can achieve.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top