Select head element by tag name
Clean up HTML before insertion