12

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:

  • Safari
    • 1.0
    • 1.2
    • 2.0
    • 3.0
    • 4.0
    • 5.0
    • 5.1
  • Chrome
    • 2
    • 6
    • 14

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?

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
  • not sure but I think it works on the mobile browser versions like on the iPhone... – Yahia Sep 25 '11 at 12:53
  • @Yahia: hm — I’ve tried the test page above on iOS 4.3.5, and neither `::-webkit-selection` nor `::selection` work. – Paul D. Waite Sep 25 '11 at 13:02
  • 2
    iOS uses a custom selection control which would explain why it doesn't work. – BoltClock Sep 25 '11 at 13:05
  • 1
    `::selection` is supported by Safari 1.3 and later (probably even starting from 1.0), as well as all versions of Chrome and any other browser that uses WebKit. [MDN lists `::selection` as the one used by WebKit-based browsers too.](https://developer.mozilla.org/en/CSS/%3a%3aselection) I wouldn't be surprised if the prefixed version was made up by people ignorant enough to assume every named thing in CSS3 has to have all the vendor prefixes. As to why it's on a site like quirksmode.org, I'm not sure, but good to check with PPK himself. – BoltClock Sep 25 '11 at 13:09
  • @BoltClock - Possibly because the quirksmode page was posted well over a year ago and hasn't been updated. – Rob Sep 25 '11 at 13:26
  • @Rob: perhaps, but I’ve tested it in versions of Safari that were around then. As far as I can tell, the selector has never been supported in WebKit. – Paul D. Waite Sep 25 '11 at 13:48
  • I'm thinking of dropping a bounty since nobody but a person who can't read has passed by since you posted :/ – BoltClock Oct 28 '11 at 08:51
  • @BoltClock: yeah, no response from PPK as of yet. I have purchased an old PowerPC Mac, so I will check in Safari 1.0 at some point. – Paul D. Waite Oct 28 '11 at 09:33
  • 1
    Just for the record, `::selection` is no longer in CSS3 — it may return in CSS4 UI, but nobody knows right now. I'll leave that [css3] tag in anyway, though... – BoltClock Jul 01 '12 at 13:55
  • Looks like PPK has updated the page, finally. – BoltClock Sep 26 '13 at 14:34
  • @BoltClock: ah yes, no `::-webkit-selection` on PPK's page any more. – Paul D. Waite Sep 26 '13 at 15:09

1 Answers1

3

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.

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
  • 1
    Is it true that it still supports `::selection`? It doesn't appear to work in iOS 9 for me and http://caniuse.com/#feat=css-selection claims its not supported for iOS 8 or 9. – Jon Brooks Apr 21 '16 at 23:00
  • @JonBrooks: no idea, I only tested the versions stated in the question. Interesting that support got removed. – Paul D. Waite Apr 22 '16 at 00:53