Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I nest form tags in other form tags?

Tags:

html

forms

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

For example:

<form>
  <form>
  </form>
</form>
like image 311
Navruk Avatar asked Dec 23 '10 14:12

Navruk


1 Answers

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

like image 153
Quentin Avatar answered Sep 24 '22 05:09

Quentin