Tidy up your HTML code

Today's Best Tech Deals

Picked by Macworld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

If you write HTML code by hand, you may already be familiar with tidy, a program that checks your code, tells you where there are errors, and, in some cases, corrects them. Tidy is an open-source program that is available for many platforms, and is also included in certain text editors, such as BBEdit or TextMate.

But since Tiger, Mac OS X includes a command-line version, located at /usr/bin/tidy. You can generate cleaned-up versions of HTML, XML, and XHTML files, and you can even convert files among these different formats. For example, you can Convert HTML to well-formed XML and output to a new file (hit control-D after the output is finished):

tidy -asxml test.html -output fixed.xml

If you just want to display errors and quit:

tidy -errors test.html

Or if you want to change all your tags to upper case:

tidy -upper test.html

For more on using the command-line version of tidy, type

man tidy
in Terminal.

If you don’t want to use the command line, and don’t work with one of the text editors mentioned above, you can install Tidy Service, which adds this functionality to your Services menu for use with Cocoa applications.

However you use it, Tidy will help you not only write correct HTML code, but also clean up any unnecessary tags. It can save you time and make your Web pages better and more efficient.

Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read our affiliate link policy for more details.
Shop Tech Products at Amazon