Easy Code Checking With Unicorn: the W3C’s Unified Validator

As a SitePoint reader, you understand the importance of code validation. Even if you’re not a semantic shaman, fixing problems is far easier when you know your HTML and CSS is valid. There are many online and offline tools to help your validation efforts but you normally need to test HTML, CSS, and feeds separately. HTML5 validators are also in short supply.

The W3C’s Unicorn project could save your sanity. It’s a unified system which aggregates results from several validators to produce a single mark-up report. It includes checks for:

  • HTML — including HTML4, XHTML and HTML5
  • CSS 1, 2, 2.1, and 3 (although it appears to default to 2.1)
  • SVG basic and tiny
  • mobile device ‘suitability’
  • feed checkers for formats including RSS and Atom

The tool can be used online at validator.w3.org/unicorn/ or you can download the open source Java code for offline usage.

Web Developer Toolbar integration

If you’re using the WDT extension for Firefox (not Chrome — sorry), you can add Unicorn as a validation tool. Open the WDT Options dialog and choose Tools in the left-hand pane. Click Add then enter:

  • W3C Unicorn for the description
  • choose URL for the tool type, and
  • enter the URL
    http://validator.w3.org/unicorn/check?ucn_task=conformance&ucn_uri=

WDT options

OK your way out and you should now find the Unicorn entry in your WDT Tools menu.

Have you tried Unicorn? Did your site pass validation? Will you use the tool regularly?

Win an Annual Membership to Learnable,

SitePoint's Learning Platform

  • AndrewCooper

    I’ve used Unicorn before and all my sites pass validation, in fact on the day they announced it I started using it as it’s utter brilliance and so much more convenient.

    What I’m annoyed about is the fact that the W3C Unicorn page was either hacked or the administrator was messing around and made all the text content on the page in l33t speak – Nobody posted any news item on this and I assumed somebody would so I never screenshotted it :(

  • http://www.tyssendesign.com.au Tyssen

    Good tip about adding Unicorn to WDT; I hadn’t thought about doing that.

  • fcphdJim

    Tried it. It’s a nice tool, especially added to the FF Web Developer toolbar. However, it seems the only way to check for CSS3 is to go to the stylesheet validator and change the default, which rather defeats the purpose of a one-touch validator. Worse, it doesn’t recognize -moz and -webkit, so any CSS3 elements using those still don’t validate. I’d say it’s a good start, but not quite ready for prime-time.
    Jim

  • http://codefisher.org/ codefisher

    I will not be using it much. For most of my validation needs I use The HTML Tidy extension for Firefox http://users.skynet.be/mgueury/mozilla/ which saves a lot of time checking pages, so I can tell with out doing any work that this page has 13 validation errors.

    It would be really nice it it had HTML 5 support, and also validated CSS3 at the same time. Which is what I will now be using Unicorn for. I had not see it yet.

  • http://www.consolegaming.eu Rjs37

    It’s a bit of a shame that it doesn’t currently work with authentication. I have sites I’m currently working on using authentication to make sure others can’t access it. Works in the other W3 validators but not Acorn. Hopefully they’ll implement that soon.

  • mech7

    Yes the extensions for firefox is awesome I use it too :) hope they integrate html5 validator soon…

  • LFA

    My god!
    Sitepoint.com fails miserably! Who’s checking your code?

    //Fredrik

  • Jean-Gui

    Hi,

    Being one of Unicorn developers I’m going to try to answer some comments.

    First of all, in the article you say “you can download the open source Java code for offline usage”. This is not completely true as to use Unicorn offline you would also need to download the other validators that Unicorn uses (markup, css, feed, mobileok).

    @AndrewCooper: not hacked, we exposed an easter egg (there are two more… happy hunting) by accident 0:-)

    @fcphdJim: actually, CSS3 is checked as part of the default task, as well as CSS1, CSS2 and CSS2.1. But only one of these tests is displayed. The display priority is CSS2.1, CSS2, CSS3, CSS1. The rationale behind this is that CSS2.1 is “soon” to be a REC (and is only a “fixed version of CSS2″) while CSS3 is much farther to becoming a REC and CSS1 is a bit old now. If you think we should do something different, I invite you to start a discussion to the public mailing list public-qa-dev@w3.org.
    And about proprietary extensions (-moz and -webkit), the culprit is not Unicorn but the CSS Validator. There have been some discussions in the past but they never reached a consensus, even within the W3C Team.

    @Rjs37 HTTP Auth is planned indeed. See http://code.w3.org/unicorn/ticket/105

    @mech7 Not sure if you are talking about WDT or Unicorn, but Unicorn can validate HTML5 documents, as does the online markup validator.

    Cheers

    • http://www.optimalworks.net/ Craig Buckler

      Thanks Jean-Gui — keep up the good work!