1750

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
  • 13,720
  • 10
  • 55
  • 101
Joey Morani
  • 25,431
  • 32
  • 84
  • 131
  • 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]) – Adriano 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
  • 1
    try this css, it work for me `textarea:focus, input:focus{ border: none; }` – Yosep Tito Jun 25 '20 at 09:38

11 Answers11

3141

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
  • 23,522
  • 33
  • 131
  • 186
CEich
  • 31,956
  • 1
  • 16
  • 15
  • 44
    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
  • 70
    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
  • 70
    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
  • 56
    @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
  • 1
    Everyone loves to point out the inaccessibility of this. Forgetting that we often work with designers/managers who care little for accessibility. Even after fighting in its corner (in my experience). We all know its bad, but we also need to know answers. – Bagseye Jun 23 '22 at 09:48
  • I have put a lot of care into the visual look of my appllication. I absolutely do not want it messed up with orange outlines. I also am, generally, infuriated by systems that assume they know what is best for me, and force me to comply. I agree with Crispen Smith that we developers should be able to choose our strategy. If the systems people have nothing to do, they might try fixing all the bugs and anomalies we have to cope with. – Betty Mock Aug 26 '22 at 22:43
  • In my case this worked border: none; – ammad khan Jan 17 '23 at 07:51
  • This did not work for me on latest Windows Chrome. – ChrisJJ May 01 '23 at 21:30
  • " border: none" did work. – ChrisJJ May 01 '23 at 21:30
292

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
  • 13,720
  • 10
  • 55
  • 101
gwintrob
  • 3,253
  • 2
  • 18
  • 14
136
input:focus {
    outline:none;
}

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

johannchopin
  • 13,720
  • 10
  • 55
  • 101
azram19
  • 1,787
  • 1
  • 9
  • 6
  • 3
    Instead of input:focus{ outline: 0; } -> outline:none; Works – BetaCoder Jan 14 '14 at 08:18
  • 23
    Don't do it unless you provide some other styling, it's important for accesability. see http://www.outlinenone.com/ – mattumotu Jul 29 '14 at 15:17
  • 1
    Actually, this CSS isn't enough. For example, if you're using JQueryUI tabs, the ugly blue border appears after you click on a tab, if you just use your CSS. You do need to add a:focus or li:focus, to prevent the border. – Mike Gledhill Dec 30 '14 at 13:16
  • this is bad for accessibility and shouldn't be done. – CommonSenseCode Jan 15 '21 at 22:03
  • I am working with https://www.npmjs.com/package/react-phone-number-input And this solution worked just fine. THanks – Dholu Aug 10 '23 at 14:37
76
<input style="border:none" >

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

Kailas
  • 7,350
  • 3
  • 47
  • 63
62

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
  • 25,431
  • 32
  • 84
  • 131
33

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

*:focus {
    outline: none;
}
johannchopin
  • 13,720
  • 10
  • 55
  • 101
nonamehere
  • 365
  • 3
  • 2
29

Solution

*:focus {
    outline: 0;
}

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

johannchopin
  • 13,720
  • 10
  • 55
  • 101
Touhid Rahman
  • 2,455
  • 21
  • 22
20

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,633
  • 15
  • 64
  • 91
Tabish
  • 1,592
  • 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
  • For me just outline:none; won't work. But solid 0px solved for me. – Chayanin Mar 20 '23 at 07:22
14

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
  • 10,145
  • 15
  • 56
  • 70
Prashant Gupta
  • 641
  • 9
  • 10
14

Set

input:focus{
    outline: 0 none;
}

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

Ivanka Todorova
  • 9,964
  • 16
  • 66
  • 103
madd
  • 339
  • 2
  • 8
12

I found out that you can also use:

input:focus{
   border: transparent;
}
bgilham
  • 5,909
  • 1
  • 24
  • 39
Refilon
  • 3,334
  • 1
  • 27
  • 51
  • 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