Validate HTML structure while parsing