command line html validator

January 31, 2009

valid HTML is something we should strive to achieve.

W3C Validator is an invaluable tool to do just that.
unfortunately, validating a local file you are working on can be annoying after the 100th time you’ve uploaded it to the W3C website.

Here you can find a command line HTML validator that simply uploads anything passed to it from stdin to the W3C Validator.

The basic syntax is:
$> python validate.py < file_to_validate.html

enjoy!

Note: before using the file, rename it from validatepy.pdf to validate.py. unfortunately, I’m not allowed to post .py files on this website…

Advertisements

2 Responses to “command line html validator”

  1. Venus098 Says:

    can I ask why is having validated code so important? I can see why having an accessible site is important, but I fail to see how the two are connected.

    • lbolla Says:

      for a long answer, I recommend this link.

      my own personal (short) answer is that a “valid” html is safer, more portable and more “honest” to the final user. safer because sticking to the rules avoids trivial programming errors. more portable because all standard compliant browsers (not many today, but the number is increasing every day…) will render standard pages in the same way and testing will be easier. more honest because using browser-dependent “features” (here including the exploitation of browser-dependent “bugs”) is going to break the site as soon as the user tries to use another browser: the consequence is that the average user will revert to the previous, buggy one in order to view the non-standard compliant website, keeping it alive… and we all want non-standard compliant browsers to die, don’t we?

      standards are there so that people do not need to reinvent the wheel or support someone else’s wheels, too…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: