There are a few references on the internet to ::-webkit-selection
, a WebKit-specific version of the ::selection
selector.
See e.g. http://www.quirksmode.org/css/selection.html (Edit: PPK has since removed ::-webkit-selection
from that page.)
However, I haven’t been able to get the example in the page above, or my own examples, to work in any WebKit-based browser. I’ve tried:
The unprefixed ::selection
selector works in all of these browsers anyway, so it’s not really a problem. But I was wondering where the references to the WebKit-specific version of this selector had come from.
Has anyone ever used it?
Since last year, WebKit supports many selectors defined in the draft of CSS Selectors Level 4. In this post, we will see a special subset of new selectors: new pseudo classes that take other selectors as arguments. Those are :matches (), :not (), :nth-child (), and :nth-last-child ().
This new selector is used extensively inside WebKit itself to simplify stylesheets. For example, code like the following used to appear in Web Inspector: The argument inside :matches () does not have to be a list of simple selectors. Any selector is supported, including the use of combinators.
CSS ::selection Selector 1 Definition and Usage. The ::selection selector matches the portion of an element that is selected by a user. Only a few... 2 Browser Support. The numbers in the table specify the first browser version that fully supports the property. Numbers... 3 CSS Syntax. More ...
@supports(selector(:has(p))) { /* Supported! */ } The :not () selector is part of the same spec… Unlike :has, :not does have pretty decent browser support and I used it for the first time the other day: That’s great I also love how gosh darn readable it is; you don’t ever have to have seen this line of code to understand what it does.
I’ve tested all the way back to Safari 1.0 (using Multi-Safari), and no version supports ::-webkit-selection
(and they all do support ::selection
).
Unless this is an issue with Multi-Safari, ::-webkit-selection
has never been supported in Safari post-1.0. I guess it might have been in the public beta though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With