Is it possible to wrap html form elements in multiple form tags?

后端 未结 2 1991
轮回少年
轮回少年 2021-01-13 21:56

Would it be wrong to have every element of a form wrapped in

tags in an HTML page? Am curious as to why it would be wrong:

Basically I have

相关标签:
2条回答
  • 2021-01-13 22:18

    The question appears to be “Can an HTML document contain several forms?” The correct answer is “Yes, as long as they are not nested.” The forms will be completely distinct, each with a set of fields of its own.

    0 讨论(0)
  • 2021-01-13 22:31

    Nested forms are not allowed, according to the specification:

    Flow content, but with no form element descendants.

    Given this input in the w3 validator:

    <!DOCTYPE html><html><head><title>tit</title></head><body>
    <form action="x">
        <form action="x">
            <input type="submit" value="x"> <!-- Submitting.. Which form...?-->
        </form>
    </form>    
    </body></html>
    

    The w3 validator says:

    Saw a form start tag, but there was already an active form element. Nested forms are not allowed. Ignoring the tag.

    0 讨论(0)
提交回复
热议问题