HTML5 invalid states refactoring