I've started using the following CSS in my reset CSS to ensure my text is never re-sized on Apple's mobile devices.

* {
    -webkit-text-size-adjust: none;
}

But, this doesn't validate at w3.org. This is the only part of my CSS which doesn't validate. Is there a way to make this valid? If not, is it acceptable to leave it in or should I remove it? Is it really a problem being invalid if it's a useful piece of CSS?

4 answers

0
points
This was chosen as the best answer

Wouldn't it be better to use:

html { -webkit-text-size-adjust: none; }

rather than a universal selector that will add the declaration to every element in the tree.

As Andy says, validation fails when you know why are not an issue.

You could move the declaration to a different stylesheet for completeness.

Answered over 7 years ago by Tony Crockford
  • Yes I see that html {} would be more appropriate. And I agree, it will be better placed in a separate CSS file, I'll do that as part of making an iPhone version of the site. Thank you very much. Edward Williams over 7 years ago
Andy Ford 533
1
point

Valid HTML is a lot more important than valid CSS. I really wouldn't worry about it - it's doing what you want for webkit browsers, and is ignored by the others. No harm, no foul.

Answered over 7 years ago by Andy Ford
1
point

The CSS validator validates against certain specifications, such as 2.1 and 3. I think some rules and properties that are yet to come haven't always been included in the w3s validator engine. That is ok. Coding for standards doesn't mean that everything outside the current specs are of the devil. Coding for modern standards means following the the web standardization, draft or otherwise. Using what's behind the next horizon is a very responsible approach to web development.

Answered over 7 years ago by Jens Hedqvist
  • Thanks for your encouragement Jens. I will keep the code in. The only downside is having to remove the Valid CSS' hyperlink from the site, though once I've placed the declaration in an iPhone-only CSS document, the link can return! Thank you for your help. Edward Williams over 7 years ago
Rob 230
1
point

What you are using, with -webkit, is a "vendor specific extension" and is specified in the CSS docs, as is -moz and the others. While it may be flagged by the validator, the extensions are perfectly legal.

Answered over 7 years ago by Rob