Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of text box selection highlight on Chrome/Safari? [duplicate]

Tags:

css

When using Chrome or Safari, an active text box or text area will display a blue/orange border around the box. I have seen some sites get rid of this, but I have copied their CSS and it's still there. How do I do it?

like image 274
Chris Avatar asked Sep 23 '10 14:09

Chris


People also ask

How do I turn off text selection highlighting?

You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.

How do you remove input box highlights?

Answer: Use CSS outline propertyIn Google Chrome browser form controls like <input> , <textarea> and <select> highlighted with blue outline around them on focus. This is the default behavior of chrome, however if you don't like it you can easily remove this by setting their outline property to none .

How do I stop highlighted text in CSS?

To disable text selection highlighting in Google Chrome browser using CSS just set -user-select CSS property to none. And no prefix is required for Google Chrome and Opera Browsers.


2 Answers

The following CSS usually removes the default highlight-border:

input:focus {outline: none; } 

It's worth remembering that the outline is a useful visual feedback for the UI focus, for those users not using a mouse (keyboard navigation, for example), and it's worth substituting another visual cue to replace the loss of the outline.

like image 182
David Thomas Avatar answered Sep 28 '22 02:09

David Thomas


You can use

input:focus, textarea:focus {     outline: 0; } 

But try to give some indication to the user that the form element is focused, for accessibility reasons.

like image 36
Yi Jiang Avatar answered Sep 28 '22 01:09

Yi Jiang