Hi freepdfbooks. Welcome to the forums.
There is a tool for this, called MagicWand 2.0, but you can only get one if you are a student at Hogwarts. The rest of us muggles have to use things like the HTML Validator service, which points out any errors we've made, after which we have to fix them manually. Some code editors like Dreamweaver do highlight code errors for you, but I don't think they actually fix them for you, although they do give hints, I think.
Of course, browsers themselves correct errors to some extent (if they see an error, they try to work out what the code should have been and present that), but there's only so much they can do, and it's certainly a game of Roulette to rely on that form of error correction.