Forum Moderators: open

Message Too Old, No Replies

Setting target attribute with a style sheet?

         

Caley

11:13 am on Oct 18, 2005 (gmt 0)

10+ Year Member



ok so far ive got,

<style type="text/css"> 
<!--
A:link {text-decoration: none; color: #ffffff;}
A:visited {text-decoration: none; color: #ffffff;}
A:hover {color: #ff8000; font-style: normal; text-decoration: none }}
</style>

just wanted to know how i make sure all links are opened in the parent target

Robin_reala

11:26 am on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's an HTML issue, not CSS. To do that add the following attribute to all your links:

target="_parent"

Caley

12:56 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



yea, i know that, but i want to set it in the Style so it is set as standard for all links, becuase there are soo many links on my page that i cant be bothered going through them all,

in the style i can set hyperlinks colour and size so why not target?

katana_one

1:17 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



in the style i can set hyperlinks colour and size so why not target?

Because link target is a function of HTML, and CSS only affects how items look, not how they work.

Robin_reala

1:40 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, you could do it with a bit of Javascript but really it's going to be easier to do a find and replace.

var links = document.getElementsByTagName("a");
for ( i=0; i<links.length; i++ ) { links[i].setAttribute("target", "_parent"); }

(that's untested btw)

FocalEnergy

4:52 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



You could set the base target for the page by including the following html in your head tags:

<base target="ParentURL">

But that of course would affect every link on your page, if that's what your going for.

Here's the thing though, I believe that the Target attribute is still valid in the <a> element, as long as your not targeting any frames. Go to www.w3c.org, to find out if I am correct.

FocalEnergy

4:58 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



Ya know what, the thing about CSS, is that it is only really capable of layout and formatting, it doesn't have the ability to set target's for link's with the exception of backgrounds and some music files. HTML and all the scripting languages handle everything else, such as what you need.

tedster

4:59 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The target attribute is valid only in transitional html or xhtml, and not in a strict version. So it all depends on the DTD.

Here's an earlier thread on the topic:
[webmasterworld.com...]