Beautiful Soup - close tags more promptly?

Chris Angelico rosuav at gmail.com
Mon Oct 24 18:57:07 EDT 2022


On Tue, 25 Oct 2022 at 09:34, Peter J. Holzer <hjp-python at hjp.at> wrote:
> > One thing I find quite interesting, though, is the way that browsers
> > *differ* in the face of bad nesting of tags. Recently I was struggling
> > to figure out a problem with an HTML form, and eventually found that
> > there was a spurious <form> tag way up higher in the page. Forms don't
> > nest, so that's invalid, but different browsers had slightly different
> > ways of showing it.
>
> Yeah, mismatched form tags can have weird effects. I don't remember the
> details but I scratched my head over that one more than once.
>

Yeah. I think my weirdest issue was one time when I inadvertently had
a <dialog> element (with a form inside it) inside something else with
a form (because the </form> was missing). Neither "dialog inside main"
nor "form in  dialog separate from form in main" is a problem, and
even "oops, missed a closing form tag" isn't that big a deal, but put
them all together, and you end up with a bizarre situation where
Firefox 91 behaves one way and Chrome (some-version) behaves another
way.

That was a fun day. Remember, folks, even if you think you ran the W3C
validator on your code recently, it can still be worth checking. Just
in case.

ChrisA


More information about the Python-list mailing list