<div>Hi!<br /><br />I am trying to analyze some implementation of the HTML5 standard (https://github.com/google/gumbo-parser) And it seems to me I have found some contradictions in form processing scheme.  As I understand "parsing-main-inbody” section describes that all nested form elements should be passed:<br /><br />"If the form element pointer is not null, and there is no template element on the stack of open elements, then this is a parse error; ignore the token"<br /><br />And therefore the code like <form><div><form></div></form><br /><br />generates tree like this:<br /><br />| <form><br />|  <div><br /><br />(without nested form)<br /><br />But the end tag </form> processing procedure is described in the way which allows impossibly generate tree with nested forms. For example:<br /><br /><form><div></form><form>...</form><br /><br />implies tree like this:<br />| <form><br />|  <div><br />|    <form><br />|      …<br />(it looks like a simple typing error but here we have two nested forms)<br /><br />Maybe this become possible because </form> does not close (pop from stack of open elements) all nodes opened after <form> start tag. In parsing algorithm parser  simply removes <form> element from stack. And therefore after <form> removing there is null element pointer with current node <div> and nothing to prevent parser from inserting new <form> inside previous.<br /><br />It looks strange. But if it is a normal behavior then the reason for checking form element pointer in open <form> tag case is not clear for me.<br /><br />Can you give me any explanatory statements?<br /><br />Thanks,<br />Sofya.</div>