27

Using only html and css, how do I disable the blue (in Firefox) highlight color around an active input field. I've tried using input {outline:none;} but with no success. Thanks for the help! =)

ok,ignoring the previous code about outline, I chose the wrong property to change. What I'm trying to get is to simply remove the highlighting (whatever browser, its the bold and colored border that appears) around an active form input field, without changing or disabling the styling. Thanks =)

Kizer Yakuza
  • 747
  • 2
  • 8
  • 13

9 Answers9

32

You have to use :focus declaration. In this case:

input:focus {outline:none;}

All the input's in your project won't have the blue border.

If you want a specific attribute, use this:

input[type=text]:focus {outline:none;}

Hope it helps. =)

Paula Fleck
  • 835
  • 11
  • 21
17

See this fiddle.

It seems that you have to set some border property to make outline: none work. If you comment in the border directive, the outline disappears.

ohcibi
  • 2,518
  • 3
  • 24
  • 47
10
input {border:0; outline:none;}

should remove all borders/outlines.

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103
  • Like this you wont see the input anymore. – ohcibi Mar 16 '13 at 19:20
  • yes, exactly - but is this not what you wanted? :) try `border: 1px solid #000;` or `border: thin inset;`. please describe what appearance are you expecting... – Alex Shesterov Mar 16 '13 at 19:28
  • I wanted nothing, but the OP says he wants to get rid of the outline, that is displayed in firefox when the input is focussed. He doesnt say that he wants the border that is visible in all browsers to disappear. But setting a border seems to do the trick on FF, as I said in my answer. Chrome(ium) seems to be satisfied with just outline: none; – ohcibi Mar 16 '13 at 19:29
8

The answer is simpler than I reliased:

box-shadow:none;
Jason Slade
  • 89
  • 1
  • 3
2

Edit: my solution was way to complicated. It's simple as that:

input:focus {
  outline: none;
}

You need to target the :focus state.

Azragh
  • 59
  • 5
  • Didn't need to reset before. The code works for me without reseting. Tested on FF, Chrome and Safari and it works fine. – Jay Smoke Nov 29 '16 at 13:51
0

To remove the highlight try adding this rule to the input field(s):

-moz-appearance:none;

This can also be done for WebKit based browsers using the respective prefix:

-webkit-appearance:none;

This should take care of any borders, outline, etc. using just one CSS property. For browsers other than the WebKit pair and Firefox - Opera and IE - it's advisable to include border and outline properties too, ensuring browser cross-compatibility.

Blieque
  • 670
  • 7
  • 28
0

add !important and define the color/background-color in your css file.

#title {
    font-size: 40px;
    color: black !important;
}
Smilez
  • 113
  • 7
-1

This should work for most input types on Firefox:

input::-moz-focus-inner { border: 0; }
Mark
  • 1,564
  • 1
  • 14
  • 22
  • OP has asked a solution for any browser and not only for FF – Amit Singh Sep 23 '14 at 16:10
  • Ah I misread the parenthesis comment in the second paragraph. This fixes the "inner" border, rather than the other outline/outer border. – Mark Sep 23 '14 at 19:36
-1
button {
    -webkit-tap-highlight-color:transparent;
    -moz-tap-highlight-color:transparent;
    -o-tap-highlight-color:transparent;
    tap-highlight-color:transparent;
}
quas
  • 333
  • 4
  • 12