Balance tags properly in HTML output

Let's see if this passes on Jenkins, just to be safe.