2
/* ** ** custom select color ** ** */
::selection {
 background: #525252; /* Safari */
}
::-moz-selection {
 background: #525252; /* Firefox */
 color:#fff;
}

The above code is not passing the W3C validator, but I can't understand the reason for it.

The following error is returned:

The pseudo-element ::selection can't appear here in the context css21 [selection]

The pseudo-element ::-moz-selection can't appear here in the context css21 [-moz-selection]

1
  • Usually they give you a reason. It could possibly be the -moz prefix. Commented Feb 8, 2011 at 8:46

3 Answers 3

1
1        The pseudo-element ::selection can't appear here in the context css21 [selection]
4        The pseudo-element ::-moz-selection can't appear here in the context css21 [-moz-selection]

That's nothing to worry about, the first one is complaining because it's being tested against CSS2.1, and the second, as Kyle suggested, is because of the -moz prefix

To silence the first "error", do the following:

enter image description here

Click on the more options link and change the profile to CSS 3.

This can not silence the second error, and should probably learn to ignore this kind of errors. I know it sounds a big of a pain, unless anyone can offer an alternative suggestion?

Sign up to request clarification or add additional context in comments.

5 Comments

how can i silent it, so i know what parts to look for in the css and not check every time. with big css files it gets problematic.
Also, ::selection has been removed from Selectors level 3: w3.org/TR/css3-selectors/#selection
In a future version of the validator it is likely that there will be a mode to ignore the -vendor- prefixes.
@karlcow There's a mode to have the vendor prefixes register as warning rather than errors, you can see the drop down in the screenshot above
ah yep already fixed. :) I must have been sleeping during the commits.
0
::-moz-selection

Mozilla/Webkit specific CSS elements do not validate even under CSS level 3.

Comments

0

Today you have a problem even with ::selection because it was dropped from CSS3.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.