HTML has a concept of empty elements, as listed on [MDN](https://developer.mozilla.org/en-US/docs/Glossary/empty_element). However, beautiful soup doesn't seem to handle them properly:

```
import bs4

soup = bs4.BeautifulSoup(
    '<div><input name=the-input><label for=the-input>My label</label></div>',
    'html.parser'
)
print(soup.contents)

```

I get:

```
[<div><input name="the-input"><label for="the-input">My label</label></input></div>]

```

I.e. the input has wrapped the label.

**Question:** Is there any way to get beautiful soup to parse this properly? Or is there an official explanation of this behaviour somewhere I haven't found yet?

At the very least I'd expect something like:

```
[<div><input name="the-input"></input><label for="the-input">My label</label></div>]

```

I.e. the input automatically closed before the label.