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.
Resources
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 W3C validator is at validator.w3.org, and the source code for the validator is at validator.w3.org/source.
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.
- « first
- ‹ previous
- 1
- 2
- 3
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
Web Development News
Developer Poll
| 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








35 sec ago
36 min 7 sec ago
37 min 4 sec ago
38 min 10 sec ago
39 min 21 sec ago
42 min 50 sec ago
44 min 13 sec ago
1 hour 41 min ago
3 hours 49 sec ago
6 hours 33 min ago