How to Use Tidy to Repair HTML5 Pages - dummies

By Andy Harris

A great resource — HTML Tidy — can be used to fix your pages. You can download Tidy or just use the online version. Here is the online version with oxWheels1.html being loaded.


Unlike W3C’s validator, Tidy actually attempts to fix your page. This is how Tidy suggests the oxWheels1.html page be fixed.

Tidy examines the page for a number of common errors and does its best to fix the errors. However, the result is not quite perfect:


  • It outputs XHTML by default. XHTML is fine, but because we’re doing HTML here, deselect the Output XHTML box. The only checkbox you need selected is Drop Empty Paras.

  • Tidy got confused by the headings. Tidy correctly fixed the level one heading, but it had trouble with the level two heading. It removed all the tags, so it’s valid, but the text intended to be a level two heading is just sort of hanging there.

  • Sometimes, the indentation is off. If you set Tidy to indent every element, it is easy to see how tag pairs are matched up. If you don’t set up the indentation explicitly, you will find Tidy code very difficult to read.

  • The changes aren’t permanent. Anything Tidy does is just a suggestion. If you want to keep the changes, you need to save the results in your editor. Click the Download Tidied File button to do this easily.

Consider using Tidy when you’re stumped because the error messages are easier to understand than the W3C validator. However, never trust it completely. Until it’s updated to truly understand HTML5, it sometimes deletes perfectly valid HTML5 tags. There’s really no substitute for good old detective skills and the official W3C validator.

Did you figure out that last error? The paragraph was closed with <p> rather than </p>. That sort of thing freaks out an XHTML validator, but HTML takes it in stride, so you might not even know there is a problem.

Tidy does notice the problem and repairs it. Remember this when you’re working with a complex page and something doesn’t seem right. It’s possible there’s a mistake you can’t even see, and it’s messing you up. In that case, consider using a validator and Tidy to figure out what’s going wrong and fix it.