6

I tried to validate my css code using W3C tidy and the w3c website is showing me the error that

Value Error : font / is not a font-family value : 11px / 14px "Trebuchet MS",sans-serif

So what's wrong with it, earlier it was not a code error, I even copied some similar code from professional blogger and tried to validated it in w3c but still I'm getting this error?

1
  • Thanks to all, who took time to reply to this post. Yes the problem is with the W3C validator, is not validating the short code css and nothing wrong with my code
    – Randore
    Nov 10, 2012 at 11:33

2 Answers 2

4

This seems to be a bug that just crept in into the W3C CSS Validator. It has been reported on the validator’s discussion list: http://lists.w3.org/Archives/Public/www-validator-css/2012May/0003.html

Recently, there have been bugs especially in font-related CSS rules in the validator, since its code has been renewed and some cases were not dealt with properly. My guess is that it takes a couple of weeks to get this fixed.

You can avoid triggering the bug if you do not use the font shorthand but specify properties separately:

font-size: 11px; 
line-height: 14px;
font-family: "Trebuchet MS", sans-serif;
3
  • Expand the font shorthand to silence a bug in a validator? Oct 14, 2012 at 14:18
  • @HalilÖzgür, yes, that was the point in the suggestion. Avoiding the font shorthand is a good idea, because it’s complicated and therefore error-prone. But technically, the validator bug discussed here has now been fixed. Oct 14, 2012 at 17:53
  • 1
    @JukkaKKorpela, font shorthand is not error-prone, just some people's usage of it is. And I'd not consider it complicated. It's pretty straightforward once you get it. And shorthand usage is recommended: developer.mozilla.org/en-US/docs/CSS/Shorthand_properties, taitems.github.com/Front-End-Development-Guidelines (search for CSS Shorthand), ... Oct 14, 2012 at 19:15
1

It looks like you're trying to validate a CSS3 property in a CSS2 validator. Switch the validator profile to CSS level 3 and you'll be good.

Based on what you've said in the comments and the fact that htmlhelp.com/tools/csscheck passes it, as does my local software, I'm calling bug in the validator. W3C isn't perfect and bugs do creep in from time to time.

Your code is fine so I would just ignore it.

3
  • Thanks for the reply tooman.., I did that but the error is still coming, you can check this in validator just inputing this code #red{ font: bold 12px/14px Arial,Helvetica,sans-serif; }
    – Randore
    May 5, 2012 at 22:28
  • @Randore can you give me a link to the validator you're using? May 5, 2012 at 22:42
  • 1
    @Randore htmlhelp.com/tools/csscheck passes it, as does my local software, so I'm calling bug in the validator. W3C isn't perfect and the font reference page it links to is broken. May 5, 2012 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.