Use http://validator.w3.org/, force the XHTML 1.1 or whatever option, and check the box that says something about automatically clean up source (read through it before _using_ it, but it helps a lot of the time)