Clean up your Web pages with HTML TIDY
When editing HTML it’s easy to make mistakes. Wouldn’t it be nice if there was a simple way to fix these mistakes automatically and tidy up sloppy editing into nicely layed out markup? Well now there is! Dave Raggett’s HTML TIDY is a free utility for doing just that. It also works great on the atrociously hard to read markup generated by specialized HTML editors and conversion tools, and can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.
So as part of my manifold duties, I have inherited a website that is in the midst of a makeover. I have some templates that look fine in IE for Windows, some skeletal style pages that don’t, and a lot of old content that needs to be migrated AND made 508 compliant.
What’s a lazy but resourceful geek to do? HTMLTidy to the rescue, of course. It’s taken me a few hours of monkeying around and reading, but I found a configfile incantation that seems to do what I want.
uppercase-tags: no # XHTML is case-sensitive
uppercase-attributes: no
indent: auto # made the output readable, ie “pretty-print” it
indent-spaces: 3
write-back: yes # write output to the same file used as input: risky but expedient
wrap: 0 # don’t wrap lines, since that confuses validators
output-xhtml: yes # write output as XHTML
doctype: auto # set the doctype to match the output
And just like that, my validation errors went from 50+ (with no content, mind you) to 0 and a clean bill of health.
Now to get some real work done.