There are actually lots of legal html omissions of ending tags. In fact any time an ending tag can be inferred from other starting or ending tags (such as inferring an ending p tag by seeing another opening p tag) it is legal to omit it. See the whatwg rules if interested.
A real html parser involves lots of special rules.
https://html.spec.whatwg.org/multipa...plied-end-tags