What am I supposed to do in order to redirect an HTML form to a new tab under the strict DTD?

107 Views Asked by At

It seems the target attribute is not a part of the strict DTD. I guess this is because frames are deprecated. But what if my target is not another frame, but a new tab (target="_blank")? Is there a way to do this and still validate under the strict DTD? In some places people recommend using JavaScript to "manually" open the new tab. Is this really necessary? (Plus I'm asking specifically about forms, not simple links, which seem to be more complicated.)

By the way, I know this has been asked before (for example here What is the correct way to open a form submit in a new window now target is deprecated), but I haven't found a good answer yet.

1

There are 1 best solutions below

1
On

The target attribute is allowed again in HTML 5, which is the doctype one should be using these days. All major browsers have HTML 5 parsers, and at least updating the doctype itself is enough for now, even if you don't use any other HTML 5 features.

I would also strongly recommend you NOT use target, because that forces a browser to open a new window/tab when the user might not want to do that. Let them make their own decision on how to open a link instead.

Since your post was also tagged as XHTML 1.0 Strict, I invite you to read these links which explain why XHTML isn't necessary: