Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are nested forms valid in HTML5?

Tags:

Nested Forms Acceptable?

I can't find anything in the HTML5 doc that talks about nested forms. I'm sure it's listed on some page, somewhere (perhaps a changelog), but if not, should I assume that no-mention is the same as acceptable?

Additionally, the HTML4 doc doesn't mention it. Perhaps it's been permitted all along and I was adhering to old standards.

Previous Mentions

XHTML1.0

form must not contain other form elements.

HTML 3.0

There can be several forms in a single document, but the FORM element can't be nested.

like image 553
vol7ron Avatar asked Oct 23 '14 20:10

vol7ron


People also ask

Are nested forms allowed in HTML?

Every form must be enclosed within a FORM element. There can be several forms in a single document, but the FORM element can't be nested. The browser is responsible for handling the input focus, i.e. which field will currently get keyboard input.

Can we use form tag inside form tag?

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

What is meant by nested form?

First — what is a nested form? It is, as it's name suggests, a form within a form. More specifically, the nested form is creating or manipulating a model that differs from the model the parent form is for.

Can we write form inside form?

Though you can have several <form> elements in one HTML page, you cannot nest them. Show activity on this post. Form nesting can be achieved with new HTML5 input element's form attribute.


1 Answers

The HTML5 document does mention it in the section you link above:

Content model

Flow content, but with no form element descendants.

"Content model" means "what this element may contain". So no, nested forms are not allowed.

like image 107
lonesomeday Avatar answered Sep 19 '22 19:09

lonesomeday