views:

207

answers:

2

Why WHATWG disallows nested forms in HTML 4 and HTML5?

EDIT: Problem is originally described at http://stackoverflow.com/questions/597596/how-do-you-overcome-the-html-form-nesting-limitation

In short author says: You are making a blog app and you have a form with some fields for creating a new post and a toolbar with "actions" like "Save", "Delete", "Cancel"... The only problem is that pressing "Delete", will submit ALL the form fields on the server even though the only thing needed for this action is a Hidden input with the post-id.

So, it is a question about an elegant solution (without JavaScript) for several buttons in a form to submit different sets of input fields (like several forms could allow) and to line up UI into single entity ("form") from user perspective.

Comment from that discussion: it's almost impossible to completely separate the elements' screen position from their position in the document.

EDIT: I found interesting note http://anderwald.info/internet/nesting-form-tags-in-xhtml/ - that (X)HTML disallows nesting forms like "form > form", but allows "form > fieldset > form", W3 validator says it is valid, but browsers have bugs with such nesting.

A: 

WHATWG doesn't disallow nested forms in HTML 4 — they have nothing to do with the language, and they don't have as much to do with HTML 5 as you seem to think.

Nested forms are not allowed because they wouldn't make sense, and if you specified something vaguely sane, it wouldn't be backwards compatible with current browsers.

David Dorward
But http://stackoverflow.com/questions/597596/how-do-you-overcome-the-html-form-nesting-limitation does make sense for me.
Nishi
A: 

As far as HTML5 (the draft spec) goes, the situation is not nearly as clear cut as David Dorward suggests. What is true, is that there's no way that nested forms can be specified in the text/html serialization in a backward-compatible way without adding a new way of delimiting forms in markup.

On the other hand, in the application/xhtml+xml serialization, it's not only possible to markup nested forms, but HTML5 goes to some lengths ( http://dev.w3.org/html5/spec/forms.html#form-owner ) to specify what should happen in this case. Further, a quick test around the latest versions of FireFox, Opera, Chrome, and Safari, plus IE9 platform preview shows that they all do what HTML5 specifies.

So, it could have been valid in the HTML5 content model, but it isn't. What determines what is valid and what isn't rests largely on use-cases. So far, no one has provided a sufficiently compelling use case to WHATWG or the W3C HTML WG for making nested forms a part of valid HTML5.

Alohci
I edited the question and added a link to the use case... How do you think, is it a sufficiently compelling use case?
Nishi
Form attribute (form owner) from HTML5 seems to solve the case, it is cool, thanks!
Nishi