Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7067961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:15:54+00:00 2026-05-28T05:15:54+00:00

I am getting a W3 validation error when linking to a stylesheet using a

  • 0

I am getting a W3 validation error when linking to a stylesheet using a media query to target retina displays. Here is the code:

<link rel='stylesheet' type='text/css' href='/css/styles-retina.css' media='only screen and (-webkit-min-device-pixel-ratio: 2)'/>

The W3C error reports:

“Bad value only screen and (-webkit-min-device-pixel-ratio: 2) for attribute media on element link: Expected a letter at start of a media feature part but saw – instead.”

I’ve searched for this and am starting to think that there isn’t a “valid” solution to this, either to ignore the validation error or remove this query altogether. I understand validating the code isn’t always useful, but is there a way in this situation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:15:54+00:00Added an answer on May 28, 2026 at 5:15 am

    The -webkit filter is not valid for W3C. Also the value for media='' is no W3C standard. You can see all allowed media types here: http://www.w3schools.com/CSS/css_mediatypes.asp

    There is no real solution validating your code but you could do a workaround, but this doesn’t really validate your code:

    PHP Workaround:

    function w3c(){
    if((stristr($_SERVER["HTTP_USER_AGENT"],'w3c') === FALSE))
    return true;
    }
    

    Use the PHP workaround like this for every content that shouldn’t be visible for the W3C validator:

    <?php if(w3c()){ ?>
        <link rel='stylesheet' type='text/css' href='/css/styles-retina.css' media='only screen and (-webkit-min-device-pixel-ratio: 2)'/>
    <?php } ?>
    

    Javascript Workaround:

    Javascript is also not visible to the W3C validator so you could also use this workaround (just keep in mind that javascript can be disabled):

    <script type="text/javascript"><!--
    document.write('<link rel='stylesheet' type='text/css' href='/css/styles-retina.css' media='only screen and (-webkit-min-device-pixel-ratio: 2)'/>');
    //--></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this error: The remote certificate is invalid according to the validation procedure.
I am having problems getting validation to work for a form built using Zend_Form.
I've been getting a validation of viewstate error for a long time on my
I'm getting an odd HTML validation error from this piece of JavaScript any help
I am getting following error while using POCO entity width EF One or more
I am getting a validation error from the following XSD: <?xml version=1.0 ?> <xsd:schema
I am trying to validate my page and getting the following w3 validation error
I'm getting Validation (): Attribute 'Factory' is not a valid attribute of element 'ServiceHost'.
I'm just getting started with ASP.NET MVC 2, and playing around with Validation. Let's
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.