Re: Excluding linked stylesheets on CSS validator?

Hi Jaime;
As far as I am aware there is no option built in.

However if you are using PHP you could do this:
instead of
<link href="style.css" rel="stylesheet" media="print" type="text/css" />
do this:
<?php
//if W3C validator don't use stylesheet
if (stristr($_SERVER["HTTP_USER_AGENT"],'w3c') === FALSE) {
     echo '<link href="style.css" rel="stylesheet" media="print" 
type="text/css" />';
}
?>

or use a get req:
<?php
if (!isset($_GET["skipexternalcss"])) {
     echo '<link href="style.css" rel="stylesheet" media="print" 
type="text/css" />';
}
?>

neither of those options are perfect and I prefer the second given your 
use case but both should work.

regards;
Nick

Nick Wilde
BriarMoon Design
www.briarmoon.ca/design/
www.facebook.com/BriarmoonDesign/

On 28/09/2013 6:23 AM, Jaime Iniesta wrote:
>
>
>
> 2013/9/28 Jens O. Meiert <jens@meiert.com <mailto:jens@meiert.com>>
>
>     > Is there any way to exclude the linked stylesheets from the
>     validation, so
>     > only the styles defined within the page itself are validated?
>
>     Just out of curiosity, what’s the benefit of this, or what particular
>     use case do you see for this?
>
>
> The use case for this is site-wide validation. When you're validating 
> multiple pages of the same site, you'd rather see the CSS errors 
> reported for the exact resource they appear on.
>
> Say, for example, you're validatiing a site with 100 pages, and each 
> of the pages links to the same stylesheet, that has 25 errors. Instead 
> of seeing this result:
>
>     page001.html # 25 errors
>     page002.html # 25 errors
>     ...
>     page100.html # 25 errors
>
> I'd rather see this:
>
>     styles.css   # 25 errors
>     page001.html # 0  errors
>     page002.html # 0  errors
>     ...
>     page100.html # 0  errors
>
> Also, as the CSS validator always seems to validate the linked 
> stylesheets, you're generating extra traffic on the validated site. 
> For each page validated, it will fetch the HTML page and each of the 
> linked stylesheets, so in this case, to validate 100 pages you're 
> doing 200 requests to the server, while if you could tell the 
> validator to exclude linked stylesheets (and validate them 
> separately), you'd be doing 101 requests in this case.
>
> But, anyway, this is only a use case, I think it's fine that the CSS 
> validator includes the linked stylesheets on the validation for single 
> page validations, but in the case of site-wide validation, it would be 
> useful to be able to exclude them and validate them separately, as an 
> option.
>
> Regards,
> Jaime

Received on Saturday, 28 September 2013 14:53:37 UTC