Forum Moderators: open

Message Too Old, No Replies

opening a link in a new window with XHTML

target="_blank" does not validate

         

teylyn

2:41 am on Dec 20, 2005 (gmt 0)

10+ Year Member



I'm in this major project of re-coding our web site in XHTML 1.0 strict. We have several links that I want to open in a new window. So far I have used something like

<a href="http://www.widgets.com" target="_blank">Widgets</a>

But this code does not validate with XHTML 1.0 strict. I get an error message Line 58 column 63: there is no attribute "target". I'm a bit confused, since the documentation on the page [w3.org...] says:

<!--================== The Anchor Element ================================-->

<!-- content is %Inline; except that anchors shouldn't be nested -->

<!ELEMENT a %a.content;>
<!ATTLIST a
%attrs;
%focus;
charset %Charset; #IMPLIED
type %ContentType; #IMPLIED
name NMTOKEN #IMPLIED
href %URI; #IMPLIED
hreflang %LanguageCode; #IMPLIED
rel %LinkTypes; #IMPLIED
rev %LinkTypes; #IMPLIED
shape %Shape; "rect"
coords %Coords; #IMPLIED
target %FrameTarget; #IMPLIED
>

Here, the attribute target is listed as a valid attribute, but I don't know what to make of the gobbledeegook. Is there anywhere I can look up what's allowed or what's allowed instead that simple people can understand? My inbuilt parser just does not read this :(

cheers

teylyn

tedster

3:12 am on Dec 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In strict HTML 4.01 or XHTML, target is not valid. It takes scripting to open a link in a new window with valid mark-up. Sometimes I just use target and know that ithis one thing won't validate. But usually, I use javascript.

This issue has been kicked around here for almost three years. For more from me on the topic, check message #8 in this thread: [webmasterworld.com...]

teylyn

7:44 pm on Dec 20, 2005 (gmt 0)

10+ Year Member


Thanks tedster, that was a great help. I've read throught the thread you provided in your link and all the sub-links and discussions, too.

Just for convenience's sake, the Sitepoint article [b]New-Window Links in a Standards-Compliant World[/b] by Kevin Yank has moved to a new place and now can be found at

http://www.sitepoint.com/article/standards-compliant-world

I have not decided which method to use, but right now lean towards Kevin's variety.

cheers

teylyn

kaled

12:08 am on Dec 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only sensible attitude is to ignore the mindlessly stupid, imbecilic buffons that set the standard and use the target attribute anyway.

Kaled.

PS: TOS prohibit me from saying what I really think.

encyclo

5:25 pm on Dec 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only sensible attitude is to ignore the mindlessly stupid, imbecilic buffons that set the standard and use the target attribute anyway.

... or just use a standard which contains the elements and attributes you require. It is no different than someone saying that they want to use XHTML 1.0 Strict but they want to keep their

<font>
tags. I disagree with the approach of the Sitepoint article which gives a rather pointless "solution" to a non-existent problem.

If you want to use the

target
attribute, why not just use XHTML 1.0 Transitional? Your page will validate just fine without any hacks.