john
john

Reputation: 87

Any idea on how to change textarea selection color?

I've tried this, but it won't work (in Chrome and IE) in case of textarea :(

::-moz-selection {
  background: #b3d4fc;
  text-shadow: none;
}
::selection {
  background: #b3d4fc;
  text-shadow: none;
}

Are there ary way to make it possible?
CSS or jQuery any how?

Upvotes: 3

Views: 6954

Answers (4)

I have found the following solution:

.YourForm textarea:focus {
  background-color: #000;
}

Upvotes: 0

Axll
Axll

Reputation: 55

If I understand correctly you want to change the background color of a textarea, right?

something like this:

textarea{
    /* Change the color of the typed text in the textarea */
    color: #CCC;

    /* Change the background color of the actual textarea */
    background-color: #000;
}

or with a class:

css->

.classname{
    /* Change the color of the typed text in the textarea */
    color: #CCC;

    /* Change the background color of the actual textarea */
    background-color: #000;
}

html->

<textarea class="classname">
</textarea>

Upvotes: -2

bpoiss
bpoiss

Reputation: 14003

This is only supported in Firefox (and Safari?).

You can do a workaround. Instead of textarea use div with contenteditable.

See: http://jsfiddle.net/VF4tb/1/

Upvotes: 4

james246
james246

Reputation: 1904

Are you trying to change the background colour of the textarea or just the colour of the text inside it? If the latter, then this is what you want:

::-moz-selection {
  color: #b3d4fc;
  text-shadow: none;
}
::selection {
  color: #b3d4fc;
  text-shadow: none;
}

As seen here: http://jsfiddle.net/u6CNN/

You can also specify a background-color too, by the way.

Upvotes: 3

Related Questions