Independent Articles and Advice
Login | Register
Finance | Life | Recreation | Technology | Travel | Shopping | Odds & Ends
Top Writers | Write For Us


PRINT |  FULL TEXT PAGES:  1 2 3 4
HTML Tidy: The Easy Way to Clean Your Web Pages 
 
by Scott Nesbitt July 11, 2005

A Touch of Style

Thanks the influence of Netscape and Microsoft, far too many Web authors use extensions like <font> and <center>. Tidy has a neat option for replacing these tags with Cascading Style Sheet (CSS) properties, making the markup compliant with the HTML 4.01 and XHTML standards.

The CSS option does a good job of replacing non-standard markup, but not with the CSS you might use. The CSS Tidy adds to a file looks something like this:

<style type="text/css"> :link { color: #0000ff } :visited { color: #800080 } li.c10 {list-style: none} p.c9 {font-family: Arial; font-weight: bold} b.c8 {font-family: Arial} div.c7 {margin-left: 2em} p.c6 {font-family: Arial; font-size: 120%; font-weight: bold} b.c5 {font-family: Arial; font-size: 120%} p.c4 {font-size: 80%} span.c3 {font-size: 80%} p.c2 {font-family: Arial; font-size: 150%; font-weight: bold} b.c1 {font-family: Arial; font-size: 150%} </style>

You'll undoubtedly need to do some manual editing to fit the tidied files into your format.

XML and XHTML Anyone?

Being on the cusp of Web standards, Tidy also supports XML and XHTML. Using configuration file options, you can convert an HTML file to XHTML or XML. Or at least that's what the documentation says. The XHTML conversion works very well. Tidy adds the XHTML document type and namespace to the header of an HTML file, and converts HTML tags to their XHTML equivalents. For example, tags like <br> and <hr> become <br /> and <hr />. The conversion checks out using the W3C's XHTML validator, and renders well in any browser.

I've never had much luck converting a Web document to XML, however. Instead of an XML file, the output is still HTML. This was really the only disappointing aspect of Tidy. But that doesn't mean it has no XML capabilities. Using the -asxml command line option, Tidy can fix errors in XML files. Not every error mind you -- Tidy can't cope with CDATA (text intended to be interpreted as containing no XML markup) for example -- but it catches most of the major ones.

PREV PAGE 1 2 3 4 NEXT PAGE

 




Home  |  Write For Us  |  FAQ  |  Copyright Policy  |  Disclaimer  |  Link to Us  |  About  |  Contact

© 2005 GoogoBits.com. All Rights Reserved.