Can I nest form tags in other form tags?

Can I put a <form> tag inside another <form> tag?

For example:

<form>
  <form>
  </form>
</form>

No, nested forms are forbidden.


This is expressed in the HTML 4.01 DTDs as:

<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->

— http://www.w3.org/TR/html4/interact/forms.html#h-17.3

This means A FORM has a mandatory start tag, mandatory end tag and can contain anything in %block or SCRIPT, except other FORMs.


XML DTDs aren't as expressive as SGML DTDs so in XHTML this rule is specified only in the human readable text of the specification:

form must not contain other form elements.

— http://www.w3.org/TR/xhtml1/#prohibitions


HTML 5 isn't an SGML application and doesn't have an official machine readable description of the language. It also expresses this rule in text:

Content model:

Flow content, but with no form element descendants.

— http://www.w3.org/TR/html5/forms.html#the-form-element


You can't nest them, but you can group elements...there's a mechanism specifically for this, the <fieldset> element, used to group controls/labels...and in HTML5 associate it to specific forms, disable contents, etc.


Nested forms are not allowed per the specification (I'm not sure what the behavior would be when attempted, I haven't tried it).

There's some interesting discussion of the topic in a previous question, however.