At the Forge - Checking Your HTML
The W3C validator is excellent, but it doesn't always catch everything, such as empty tags. For this, you might want to add to your arsenal, integrating the open-source Tidy library, which identifies and fixes badly written HTML. Tidy originally was written by Dave Raggett, one of the best-known developers from the early days of the Web; the project is now on SourceForge at tidy.sf.net.
To integrate Tidy checking into your Rails application, first install the library from SourceForge. Then, install the Ruby gem for Tidy integration:
sudo gem install tidy
Finally, download and install the Rails Tidy plugin:
cd vendor/plugins wget http://www.cosinux.org/~dam/projects/rails-tidy/rails_tidy-0.3.tar.bz2 tar -jxvf rails_tidy-0.3.tar.bz2
Now, modify test_helper to read:
ApplicationController.validators = [:w3c, :tidy]
With that in place, every request to your server now will be checked by both validators, rather than just one.
The Rails Tidy plugin can be useful beyond checking and validating to fix your HTML as it is sent from your server to the user's browser. Although I like this idea in theory, it seems fairly inefficient and slow to parse and rewrite every bit of HTML as it is sent. Plus, I feel that debugging Web applications (and CSS) is tough enough without having the HTML magically rewritten behind the scenes.
HTML has evolved quite a bit over the years, and getting your pages to contain valid HTML can be difficult to handle manually. For this reason, using automated checks and integrating those checks into a Web application's automated settings is a good way to ensure that your site is adhering to HTML standards as closely as possible. This not only gives you the greatest chance of having the site render similarly on different platforms, but it also even may boost your ranking in Google (an assertion I have seen mentioned in several places, but for which I obviously have no proof).
If you are using Ruby on Rails, you can validate your HTML easily from the start of your project. By doing so, you will make life easier for yourself down the line. Moreover, this is far easier than checking pages manually, and it ensures that even administrative and other hidden pages are validated.
The Web Developer plugin for Firefox, which has been an invaluable help in my work for several years, is at chrispederick.com/work/web-developer. It contains a link to the public W3C validator, allowing you to check the page that your browser currently is viewing.
Some examples of valid HTML (and XHTML) document declarations are at htmlhelp.com/tools/validator/doctype.html.
The home page for the Tidy library is at tidy.sf.net. The home page for the Tidy gem for Ruby is rubyforge.org/projects/tidy. The home page for the Rails Tidy plugin is at www.cosinux.org/~dam/projects/rails-tidy/doc.
The html-test plugin for Ruby on Rails is at github.com/Empact/html_test/tree/master. This project at Github has some documentation, as well as the code itself.
Finally, the book Advanced Rails Recipes, edited by Mike Clark and published by the Pragmatic Programmers, has a short recipe (#57) by Peter Marklund describing the use of HTML validation from within Rails automated testing. I generally have found this book to be an excellent source of inspiration, along with informing me of many plugins and gems that I had not yet discovered.
Reuven M. Lerner, a longtime Web/database developer and consultant, is a PhD candidate in learning sciences at Northwestern University, studying on-line learning communities. He recently returned (with his wife and three children) to their home in Modi'in, Israel, after four years in the Chicago area.
Web Development News
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
|Trying to Tame the Tablet||May 08, 2013|
|Dart: a New Web Programming Experience||May 07, 2013|
- RSS Feeds
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Developer Poll
- Trying to Tame the Tablet
- not living upto the mobile revolution
35 sec ago
- Deceptive Advertising and
36 min 7 sec ago
- Let\'s declare that you have
37 min 4 sec ago
- Alterations in Contest Due
38 min 10 sec ago
- At a numbers mindset, your
39 min 21 sec ago
- Do not get Just Almost any
42 min 50 sec ago
- A fantastic rule-of-thumb to
44 min 13 sec ago
- Keren mastah..
1 hour 41 min ago
- mini tablet compare
3 hours 49 sec ago
- Looking Good
6 hours 33 min ago