HTML5 and CSS3 All-in-One For Dummies
Book image
Explore Book Buy On Amazon

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.

image0.jpg

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:

image1.jpg
  • 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

rather than

. 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.

About This Article

This article is from the book:

About the book author:

Andy Harris taught himself programming because it was fun. Today he teaches computer science, game development, and web programming at the university level; is a technology consultant for the state of Indiana; has helped people with disabilities to form their own web development companies; and works with families who wish to teach computing at home.

This article can be found in the category: