1619

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

johannchopin
  • 11,813
  • 8
  • 41
  • 91
Joey Morani
  • 23,675
  • 32
  • 81
  • 128
  • note that oulines also appear in different cases: in IE9 you can see little dots around a button if you select it using tab (ie. you click inside a field before the button & go to the next fields using Tab until you reach the button [going to previous field is Shift + Tab]) – Adrien Be Feb 11 '13 at 10:32
  • 3
    ...And in case someone needs to remove it from select elements in firefox: http://notes.jerzygangi.com/how-to-remove-the-dotted-border-from-around-select-tags-in-firefox/ – Luca Reghellin Jun 22 '18 at 14:43
  • Use **border-style: none; background-color: white; font-size: 13px; font-weight: bold; color: black;** – Phoenix Apr 23 '19 at 12:15
  • As @Torkil-Johnsen mentioned in a comment below, you might want to give a different style to make it more obvious, but to just remove it is very bad for accessibility (e.g. people who only use a keyboard or other assistive device to tab through elements). – Frank Forte Nov 07 '19 at 19:53
  • try this css, it work for me `textarea:focus, input:focus{ border: none; }` – Yosep Tito Jun 25 '20 at 09:38

11 Answers11

2904

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

CommonSenseCode
  • 21,117
  • 30
  • 122
  • 175
CEich
  • 29,554
  • 1
  • 14
  • 15
  • 40
    This is not working for me. I am using Chrome, latest update. I put `input:focus {outline: 0;}` in the CSS, but when I type, the blue Mac outline is still there. – Joe Pigott Nov 05 '13 at 20:29
  • Problem is when you already use outline. For ex : "outline: .5em solid black !important;". Chrome still does something which reduces the width and it also gets rid of the box-shadow which I'm also using. – Alain Zelink May 02 '14 at 13:54
  • 68
    Use `outline: none` – aceofspades Jun 15 '14 at 16:00
  • 5
    outline-style: none works well with Chromium (version 34) and Firefox (version 30) – Nantoka Jun 16 '14 at 13:53
  • 67
    It's bad for accessibility to remove this outline that is default on :focus. This means that users using the keyboard to navigate will have a hard time seeing which link/item is highlighted when they hit tab. If anything, the highlighting of the element should be enhanced to make it *more* obvious which item has focus. – Torkil Johnsen Jul 25 '14 at 12:46
  • 53
    @TorkilJohnsen, While I agree 100% that the element should be visibly focused the default blue/orange ring behaviour is not always the right strategy. As long as some strategy is adopted (and adopted consistently across a design system) then CSS should be authored to support that decision. – Crispen Smith Jan 27 '15 at 02:47
  • This answer promotes creating inaccessible solution which prevents a lot of people from using important applications. Even with the "accessibility warning" at the bottom, most people would not bother to read it below. This answer needs to be hidden or heavily modified so that at the top is an accessible solution and below with a big warning with working like "Previous Answer: Do not use it!" the inaccessible solution. – Renato Mar 15 '22 at 17:53
263

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;
}
johannchopin
  • 11,813
  • 8
  • 41
  • 91
gwintrob
  • 2,935
  • 1
  • 17
  • 14
128
input:focus {
    outline:none;
}

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

johannchopin
  • 11,813
  • 8
  • 41
  • 91
azram19
  • 1,707
  • 1
  • 9
  • 6
75
<input style="border:none" >

Worked well for me. Wished to have it fixed in html itself ... :)

Kailas
  • 6,928
  • 3
  • 44
  • 63
49

I've found the solution.
I used: outline:none; in the CSS and it seems to have worked. Thanks for the help anyway. :)

Joey Morani
  • 23,675
  • 32
  • 81
  • 128
31

this remove orange frame in chrome from all and any element no matter what and where is it

*:focus {
    outline: none;
}
johannchopin
  • 11,813
  • 8
  • 41
  • 91
nonamehere
  • 345
  • 3
  • 2
25

Solution

*:focus {
    outline: 0;
}

PS: Use outline:0 instead of outline:none on focus. It's valid and better practice.

johannchopin
  • 11,813
  • 8
  • 41
  • 91
Touhid Rahman
  • 2,347
  • 20
  • 22
18

Please use the following syntax to remove the border of text box and remove the highlighted border of browser style.

input {
    background-color:transparent;
    border: 0px solid;
    height:30px;
    width:260px;
}
input:focus {
    outline:none;
}
daniel__
  • 11,255
  • 14
  • 61
  • 91
Tabish
  • 1,434
  • 16
  • 13
  • 1
    Be careful with the transparent definition on the background-color attribute. You don't need that and you probably will have a big problem when you need to write something (you won't find the inputs!). By the way, personally, I would change the transparent background to select a color. For example, if my container has a red color, I would use a white background on the input. – Gilberto Sánchez Dec 28 '16 at 21:07
13

Set

input:focus{
    outline: 0 none;
}

"!important" is just in case. That's not necessary. [And now it's gone. –Ed.]

Ivanka Todorova
  • 9,533
  • 15
  • 56
  • 97
madd
  • 329
  • 2
  • 7
12

I found out that you can also use:

input:focus{
   border: transparent;
}
bgilham
  • 5,849
  • 1
  • 23
  • 39
Refilon
  • 3,094
  • 1
  • 24
  • 43
  • The question may have "border" in the title, but the OP is actually asking about the default outline – zoran404 Dec 14 '20 at 11:32
11

This will definitely work. Orange outline will not show anymore.. Common for all tags:

*:focus {
    outline: none;
}

Specific to some tag, ex: input tag

input:focus {
   outline:none;
}
hichris123
  • 9,955
  • 15
  • 53
  • 68
Prashant Gupta
  • 601
  • 8
  • 10