Forum Moderators: open

Message Too Old, No Replies

XHTML strict target attribute

alternative to this

         

natty

11:51 am on Feb 16, 2005 (gmt 0)

10+ Year Member



hi all,

when using xhtml strct, which doesnt allow the target attricbute. how does one open a link in a new page?
not using JS ofcourse.

tia

nat

encyclo

3:50 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are a few Javascript hacks around (usually using a
rel
attribute on the link instead of
target
), but they are rather missing the point. The
target
attribute was removed from the specifications in XHTML 1.0 Strict for various reasons (including accessibility), but if you want to continue using it, you can use XHTML 1.0 Transitional instead - it is just as valid a standard as Strict.

You should never sacrifice functionality or use hacks just to validate to a stricter doctype.

natty

4:39 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



hi encyclo,

thanks for the reply.
i was under the impression going for transitional was fairly pointless? i can t remember where i read that.. ok and pointless may be a bad word to use. im sure i read it on here somewhere. should bookmark more of these posts.

we decided on strict for a reason.. i however was not party to this descision. i think mostly thought it was for accessability and reliability of layout.
i think to change back to trans simply to allow target=_blank.. (oh ok and it would be nice to set table cell widths) would seem a little bit overkill?

i certainly agree.. JS for this is a total no no
and the similar rel type hacks all use this and are straight out the window.

but i only want to use this for external links. which is sort of why it was there in the first place, no?

tedster

4:43 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



which is sort of why it was there in the first place, no?

I believe it was created for links from within framesets.

encyclo

4:51 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is certainly better to go for strict by avoiding too much presentational HTML - replacing layout tables, line-breaks and font tags with CSS. However, if there are constraints which stop you from fully validating to a strict doctype, there is no problem in choosing a transitional doctype.

If you are using

target="_blank"
or simple layout tables, you could use a Strict doctype during development (noting the validation errors), then switch to a transitional doctype before the site goes live. That will allow your site to validate, but will reduce the amount of presentational elements to a minimum.

I would never give up any functionality just to have a "Strict" badge, which has no consequence to end-users and is of no interest except to the most awkward of standards advocates. Your customers just want it to work.