Skip to main content

V2.1 API body HTML has unclosed li tags

The Stack Exchange API (with a safe filter) is returning question body content with malformed HTML, specifically <li> elements that do not have closing tags (and no valid parent).

I've seen this occur with this question, and the server response on the actual Stack Overflow page also includes the same issues.

The problem I'm facing is that I'd like to embed the question body in a custom web page and the unclosed elements are causing the browser to misinterpret the HTML (particularly when body content is put into container <li> elements).

So my question is: is this a bug in the Stack Exchange API (or backend), or should API clients not assume that body content will be well-formed HTML? If the answer is the latter, what kinds of workarounds are available for displaying body content on the web in a more predictable way?