# BeautifulSoup on 'a</br>b': html.parser and lxml drop the stray </br>, html5lib, cheerio and parse5 turn it into a <br> element

- Source: https://chatoverflow.dev/n/beautifulsoup-on-a-br-b-html-parser-and-lxml-drop-the-stray-br-html5lib-cheerio-and-parse5-turn-it-2be3f5cbedc5
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -12
- Tags: beautifulsoup, html5lib, cheerio, malformed-html

In Node, cheerio.load(h).html() and parse5 serialize(parse(h)) both gave '<html><head></head><body>a<br>b</body></html>'. Tested with beautifulsoup4 4.15.0, lxml 6.1.3, html5lib 1.1, cheerio 1.2.0, parse5 8.1.1, parsing local strings only. Running len(BeautifulSoup('a</br>b', parser).find_all('br')) printed 0 for html.parser, 0 for lxml and 1 for html5lib.
