Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove focus border (outline) around text/input boxes? (Chrome) [duplicate]

Can anyone explain how to remove the orange or blue border (outline) around text/input boxes? I think it only happens on Chrome to show that the input box is active. Here's the input CSS I'm using:

input {
    background-color: transparent;
    border: 0px solid;
    height: 20px;
    width: 160px;
    color: #CCC;
}

Text box with blue outline and "Example" written in it

like image 577
Joey Morani Avatar asked Aug 03 '10 13:08

Joey Morani


People also ask

How do you get rid of the border on input focus?

Use the :focus pseudo-class with the "no-outline" class to style the form fields that are focused by the user. To have clear fields in your forms, set the outline property to its "none" value, which is used to display no outline.


3 Answers

This border is used to show that the element is focused (i.e. you can type in the input or press the button with Enter). You can remove it with outline property, though:

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

You may want to add some other way for users to know what element has keyboard focus though for usability.

Chrome will also apply highlighting to other elements such as DIV's used as modals. To prevent the highlight on those and all other elements as well, you can do:

*:focus {
    outline: none;
}


⚠️ Accessibility warning

Please notice that removing outline from input is an accessibility bad practice. Users using screen readers will not be able to see where their pointer is focused at. More info at a11yproject

like image 65
CEich Avatar answered Nov 12 '22 18:11

CEich


The current answer didn't work for me with Bootstrap 3.1.1. Here's what I had to override:

.form-control:focus {
  border-color: inherit;
  -webkit-box-shadow: none;
  box-shadow: none;
}
like image 42
gwintrob Avatar answered Nov 12 '22 19:11

gwintrob


input:focus {
    outline:none;
}

This will do. Orange outline won't show up anymore.

like image 35
azram19 Avatar answered Nov 12 '22 18:11

azram19