Bryan Hadaway's Blog
Signup for the Best Hosting Around

How to Link to the W3C CSS3 Validation Page

Automatic Method:

You should now simply use:
http://jigsaw.w3.org/css-validator/check/referer?profile=css3

Manual Method:

Typically if you want to dynamically link to a W3C Valid CSS page, we use this link:

http://jigsaw.w3.org/css-validator/check/referer

That’s perfect if you’re using ALL CSS2.1 as that’s the default checker, but if you implement even 1 CSS3 style you’ll fail validation. So, we can no longer use the referrer method until CSS3 becomes highly supported to the mainstream.

So, as a compromise, instead of linking our pages to the referrer link, we’ll have to link our stylesheet to the CSS3 Validator like so:

(remember to use & amp; with no spaces between & and amp; in place of & so you don’t break XHTML Validation)

With a little PHP magic we could generate the current page URL dynamically in place of:

http://www.website.com/css/style.css

But, you might find this difficult from the footer.php, if someone could re-work the following code to work properly when using a dynamic footer.php file please share:

Thanks for reading, Bryan

Other Reads:

Tagged in , , ,

Want to share your website, writing, product or service with all my readers too?  
  • http://www.w3cvalidation.net w3cvalidation

    Nice information, I really appreciate the way you presented.Thanks for sharing..

  • http://www.bryanhadaway.com/ Bryan Hadaway

    You bet. Thanks

  • http://w3cvalidation.net/ Anonymous

    I thank you for this useful and complete post, I was looking for post like this. I like your blog.

  • http://www.kintzele.com John Kintzele
  • http://www.bryanhadaway.com/ Bryan Hadaway

    Nice, I knew they would update it at some point. I’ll update the post, as this is definitely the best method now.

    But, no doubt my blog doesn’t validate ;). WordPress isn’t even valid out-of-the-box.

    Thanks for the update.

    Thanks, Bryan

  • http://www.serverproductions.be SerVerProductions

    Thanks a lot for this useful information! Nice blog too.

  • Sikor

    Thanks, you help me.

  • http://www.alinawaz.net alinawaz.net

    Thanks :)

  • jpogge

    This works well for me for checking xhtml and css. Change it to suit, but be careful with the double and single quotes.

    <?php
    // Construct a uri for xhtml and one for css
    $host = $_SERVER['HTTP_HOST'];
    $self = $_SERVER['PHP_SELF'];
    $xhtmluri = 'http://validator.w3.org/check?uri=&#039; . urlencode('http://&#039;) . urlencode($host) . urlencode($self);
    $cssuri = 'http://jigsaw.w3.org/css-validator/check/referer?profile=css3&uri=&#039; . urlencode('http://&#039;) . urlencode($host) . urlencode($self);

    // Use the uris constructed above in the following links to the validating services
    $xhtml = 'xhtml‘;
    $css = ‘css‘;

    echo $xhtml . ‘ | ‘ . $css;
    ?>

  • jpogge

    Somehow the initial <?php didn't make it into my post. Also, I wasn't expecting the bryanhadaway.com server to process the php code I submitted. Hopefully everyone can figure it out.

  • jpogge

    Second try omitting the php delimiters.

    // Construct a uri for xhtml and one for css
    $host = $_SERVER['HTTP_HOST'];
    $self = $_SERVER['PHP_SELF'];

    $xhtmluri = ‘http://validator.w3.org/check?uri=’ . urlencode(‘http://’) . urlencode($host) . urlencode($self);
    $cssuri = ‘http://jigsaw.w3.org/css-validator/check/referer?profile=css3&uri=’ . urlencode(‘http://’) . urlencode($host) . urlencode($self);

    // Use the uris constructed above in the following links to the validating services
    $xhtml = ‘xhtml‘;
    $css = ‘css‘;

    echo $xhtml . ‘ | ‘ . $css;

Feedback
x close