Search code examples
cssinputhighlighting

What CSS property is controlling this input highlighting?


The image below shows an input field with the text 'test' in it, immediately after clicking in the input to gain focus: enter image description here

I'm trying to remove the green highlighting (the green is coming from the OS highlight color). Here is another image illustrating the desired behavior with a normal, unstyled input: enter image description here

As you can see, the standard behavior is a cursor appearing where the user clicked, as opposed to highlighting the entire text with no cursor. What is causing this behavior?

The styling for this element is scattered all over the place, and inspecting the computed properties doesn't seem to reveal anything unusual to me. This behavior is present in Chrome and Firefox. enter image description here


Solution

  • It appears something is selecting the text on focus. You could use javascript to collapse the selection on focus.

    http://developer.mozilla.org/en-US/docs/Web/API/Selection/collapse