Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If you set the target attribute on a element it won't validate at how doe one come around this and still have it validating?

share|improve this question
Best to ask at ? – Iain Jan 8 '10 at 13:19
You can have a target element, or you can have valid code. Not both - for a good reason. But if it renders, it renders, right? – Phoshi Jan 8 '10 at 15:08
up vote 1 down vote accepted

The target attribute is still part of the HTML 4.01 standard (and works in all browsers), but it is no longer part of XHTML (which you are probably trying to validate for). There is currently no HTML-way to emulate its effect.

There is the CSS3 Hyperlink Presentation Module draft however, that would bring back such a possibility via CSS. However it is currently not implemented by any browser.

share|improve this answer
XHTML1.0 is semantically the same as HTML4, just expressed as XML instead of SGML. There is (almost) no difference in what elements and attributes are allowed. target is as valid in XHTML as HTML (that is to say, it can be valid or invalid depending on whether you're using Strict or not). – bobince Jan 8 '10 at 21:45

You can't use target in valid XHTML.

Here's a way to emulate its effect using valid xhtml with a small snippet of javascript:

share|improve this answer

<a target> is perfectly valid in HTML 4.01 Transitional and XHTML 1.0 Transitional. If you must use frame-targetting, you'll need to use one of those DOCTYPEs.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .