Factored out HTML rendering