PHP: excluding file from W3C validation

I am using the colorbox framework ( and it works great on my site.

However, the CSS does not validate and this is a known issue for this framework:

I wish to exclude colorbox.css from W3C CSS validation. I remember reading about some PHP that will do this, just by enclosing the .css source in a PHP statement, but I can’t remember where to find this…

Any help is greatly appreciated.

I love it when you see ‘this site is valid blah blah blah’ and then the validator throws hundreds of errors :slight_smile:

If you use CSS that isn’t valid, then excluding it from being validated is cheating.
It’s like asking your teacher to ignore the questions you got wrong when he’s marking your exams.


  • Fix the CSS
  • Remove the Validation buttons

Preferably both :slight_smile:

Indirect approach to fixing it: Colorbox appears to be Open Source Software.

Fix the CSS.

I have to agree with cranial here.
Excluding a page to pass validation is like excluding your income to file taxes. It’s perfectly valid on what you did submit, but that isn’t the point of the exercise.

Fix the CSS, or remove the links (i’d go with option 2)

I don’t understand the point of the validation buttons in general. I don’t think they are useful, or that users care about them. And if you have code that isn’t valid they become extra pointless.
I think the problem is a little backwards…like finding it too dark inside when wearing sunglasses. You could either remove the roof or take the sunglasses off.

You could also eliminate the validation links… :smiley:

Anyway, validation is done on the resulting HTML/CSS code, not on the PHP script. So if there is a way to exclude some parts of a page from validation (seems strange to me, but who knows), then it would have to be some kind of HTML or CSS construction.
Find out what it is, and then it shouldn’t be too difficult to implement in PHP.

Agreed - even if you do have valid code, they are pointless and make you look a bit amateurish. Anybody who cares about valid code and is bothered in seeing if you have valid code will know how to check - and to anyone else, they’re just an unnecessary distraction. And when the validation button gives the result “This page is not valid” it is worse than “extra pointless”, it is positively harmful, and makes you look totally incompetent…

I think the problem is a little backwards…like finding it too dark inside when wearing sunglasses. You could either remove the roof or take the sunglasses off.

:rofl: Brilliant!

For 2 reasons:

  1. Because the rest of my site validates perfectly
  2. I have validation links in the footer

There is no alternative other than switching jQuery frameworks and I can’t do that because colorbox has been heavily implemented. So it looks like excluding that CSS file is my only other option.


Is there any reason for this? Excluding it doesn’t make it any more valid. :wink:

I think the issue is even more basic than that. You can use the (X)HTML validation links, and it sounds like those are fine. You can’t use the CSS validation links because your site doesn’t validate. You’re stuck with a framework with bad CSS, and visitors are going to have to deal with that. As long as you don’t have the valid CSS link you should be fine. I don’t think you have any issues at all. And realistically if you’re trying to make your site “look” valid to the validation software even though its not, you have a much more basic problem, honesty and usability. Your visitors are going to be affected by the issues of bad CSS, it would be inappropriate to tell them your site’s CSS is valid. It doesn’t matter if it’s one particular stylesheet, that’s still an integral component of your website’s CSS. In my experience you don’t want to establish the expectation if you can’t deliver the goods. That’s not a bad thing. If you, your visitors, and / or your clients want to take advantage of the benefits of the framework, then bad CSS is one of the tradeoffs that goes with that. It doesn’t mean anyone is doing a bad job, it’s the evaluation process you go through with any 3rd party software / component / etc. It’s just important to be honest about what things do and wahat they don’t. It’s all about managing expectations. And that’s the big reason you wouldn’t want a valid CSS logo on the site.

That being said, IMO, I hate the validation logos. I find the entire idea tacky and never recommend using them.

Those links that indicate that a page passes validation are an indication that the page owner is still a novice when it comes to validation. Get rid of them completely and you will appear more professional.