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?

1 Answer 1


The code in question was not generated by Stack Exchange. It was generated by a user.

So, yes, quite often, the HTML (and all other code samples generated by users) will be malformed.

However, in this case, note that <li> tags are not required to have closing tags. I agree that it is bad form to leave them off, though.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .