HTML scanner and tag balancer