tags:

views:

297

answers:

2

Is there a way to apply the ::selection and ::-moz-selection css pseudo-classes to the text inside a textarea?

textarea::selection { color: #ff0000; }

Isn't working

A: 

According to this, it should work.

Can you try giving it an important?

Can you try applying it to a different element than a textarea, e.g. a div? If it works there, it works differently for input elements - but I can't find any resources mentioning that.

Pekka
It has worked for me on divs and spans. Adding an important didn't help.Oddly, on a multi-line textarea when I select the whole textarea the blank lines will be selected with the background-color I specify, but the ones with writing in them have the regular selection color.I spent all morning looking for some resource mentioning why it would be handled differently in inputs, but I can't find either that or a working example.
Trevor
This sounds like Mozilla is treating differently selections that are part of a form input. I'm afraid this might be one of those cases where nothing can be done, because the browser's input styling guidelines overrule everything else, similar to form input elements like `select` or `file` that can be customized in a very limited way only.
Pekka