Should I be using, ::selection or user-select: none;?

::selection and user-select: none; do the same thing I am finding.

I want to prevent the YouTube screen from being highlighted when I double click on the background.

Which can be seen here: https://jsfiddle.net/0fzuv45p/

The YouTube screen itself can’t be highlighted when I double click on the background.

Using both codes.

Which would be the better choice to use here?

https://jsfiddle.net/1sj9e63y/

iframe::selection {
  background: none;
}

https://jsfiddle.net/or01a8zf/

iframe{
  user-select: none;
}

If you change background: none; to a color, and then double click on the background.

You can see it is red.

https://jsfiddle.net/kmtv2d37/

iframe::selection {
  background: red;
}

Which of these should I be using to prevent the YouTube screen from being highlighted when I double click on the background?

For what I want to do, is one code/way/method preferred over the other?

https://developer.mozilla.org/en-US/docs/Web/CSS/::selection

iframe::selection {
  background: none;
}

https://developer.mozilla.org/en-US/docs/Web/CSS/user-select

iframe{
  user-select: none;
}

I was going to say user-select then I got curious how YouTube does it and they use user-select as well, so seems like the right choice I would say.

From the Styles tab on a YouTube video.

style attribute {
  touch-action: auto;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.