I would suggest using a representation language other than HTML and a template structure as described here.