Removing Safari input glow [duplicate] - html

I am wondering if its possible to remove the default blue and yellow glow when I click on a text input / text area using CSS?

Edit (11 years later): Don't do this unless you're going to provide a fallback to indicate which element is active. Otherwise, this harms accessibility as it essentially removes the indication showing which element in a document has focus. Imagine being a keyboard user and not really knowing what element you can interact with. Let accessibility trump aesthetics here.
textarea, select, input, button { outline: none; }
Although, it's been argued that keeping the glow/outline is actually beneficial for accessibility as it can help users see which Element is currently focused.
You can also use the pseudo-element ':focus' to only target the inputs when the user has them selected.
Demo: https://jsfiddle.net/JohnnyWalkerDesign/xm3zu0cf/

This effect can occur on non-input elements, too. I've found the following works as a more general solution
:focus {
outline-color: transparent;
outline-style: none;
}
Update: You may not have to use the :focus selector. If you have an element, say <div id="mydiv">stuff</div>, and you were getting the outer glow on this div element, just apply like normal:
#mydiv {
outline-color: transparent;
outline-style: none;
}

On textarea resizing in webkit based browsers:
Setting max-height and max-width on the textarea will not remove the visual resize handle. Try:
resize: none;
(and yes I agree with "try to avoid doing anything which breaks the user's expectation", but sometimes it does make sense, i.e. in the context of a web application)
To customize the look and feel of webkit form elements from scratch:
-webkit-appearance: none;

I experienced this on a div that had a click event and after 20 some searches I found this snippet that saved my day.
-webkit-tap-highlight-color: rgba(0,0,0,0);
This disables the default button highlighting in webkit mobile browsers

Carl W:
This effect can occur on non-input elements, too. I've found the following works as a more general solution
:focus {
outline-color: transparent;
outline-style: none;
}
I’ll explain this:
:focus means it styles the elements that are in focus. So we are styling the elements in focus.
outline-color: transparent; means that the blue glow is transparent.
outline-style: none; does the same thing.

This is the solution for people that do care about accessibility.
Please, don't use outline:none; for disabling the focus outline. You are killing accessibility of the web if you do this. There is a accessible way of doing this.
Check out this article that I've written to explain how to remove the border in an accessible way.
The idea in short is to only show the outline border when we detect a keyboard user. Once a user starts using his mouse we disable the outline. As a result you get the best of the two.

If you want to remove the glow from buttons in Bootstrap (which is not necessarily bad UX in my opinion), you'll need the following code:
.btn:focus, .btn:active:focus, .btn.active:focus{
outline-color: transparent;
outline-style: none;
}

This solution worked for me.
input:focus {
outline: none !important;
box-shadow: none !important;
}

some times it's happens buttons also then use below to remove the outerline
input:hover
input:active,
input:focus,
textarea:active,
textarea:hover,
textarea:focus,
button:focus,
button:active,
button:hover
{
outline:0px !important;
}

<select class="custom-select">
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
</select>
<style>
.custom-select {
display: inline-block;
border: 2px solid #bbb;
padding: 4px 3px 3px 5px;
margin: 0;
font: inherit;
outline:none; /* remove focus ring from Webkit */
line-height: 1.2;
background: #f8f8f8;
-webkit-appearance:none; /* remove the strong OSX influence from Webkit */
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
/* for Webkit's CSS-only solution */
#media screen and (-webkit-min-device-pixel-ratio:0) {
.custom-select {
padding-right:30px;
}
}
/* Since we removed the default focus styles, we have to add our own */
.custom-select:focus {
-webkit-box-shadow: 0 0 3px 1px #c00;
-moz-box-shadow: 0 0 3px 1px #c00;
box-shadow: 0 0 3px 1px #c00;
}
/* Select arrow styling */
.custom-select:after {
content: "▼";
position: absolute;
top: 0;
right: 0;
bottom: 0;
font-size: 60%;
line-height: 30px;
padding: 0 7px;
background: #bbb;
color: white;
pointer-events:none;
-webkit-border-radius: 0 6px 6px 0;
-moz-border-radius: 0 6px 6px 0;
border-radius: 0 6px 6px 0;
}
</style>

I found it helpful to remove the outline on a "sliding door" type of input button, because the outline doesn't cover the right "cap" of the sliding door image making the focus state look a little wonky.
input.slidingdoorbutton:focus { outline: none;}

I just needed to remove this effect from my text input fields, and I couldn't get the other techniques to work quite right, but this is what works for me;
input[type="text"], input[type="text"]:focus{
outline: 0;
border:none;
box-shadow:none;
}
Tested in Firefox and in Chrome.

Sure! You can remove blue border also from all HTML elements using *
*{
outline-color: transparent;
outline-style: none;
}
And
*{
outline: none;
}

Related

How to apply border to html select button?

As shown in the picture I applied a border radius for the select tag but when pressing on it the arrow button isn't taking the border radius.
(Only in Opera browser)
css:
.App select{
font-family: "Nunito", sans-serif !important;
font-size: 22px !important;
padding: 0.25rem;
border-radius: 0.5rem;
border: #dc3545 solid 1px;
outline: none;
padding-left: 15px;
}
Is there any solution for this?
The outline shown is most likely the :focus state. I would keep this on for accessibility reasons; some people physically cannot use a mouse, or simply prefer to navigate a page via the keyboard.
Knowing this, you can toggle the focus state with CSS:
:focus {
outline: none;
}
The Solution is simple, just give in:
.App select:focus {
overflow: inline;
outline: none;

How to make a input submit button with flat look?

Here I have a submit button:
<input type="submit" value="submit" />
And I want to add some additional styles to make it a flat look:
input {
border: 0;
background: none;
-webkit-appearance: none;
}
This is how it looks afterwards:
However, if you look carefully, there is still some border on the top of the submit button......
Is there some way to remove the sunken or raised surface and make it a plain flat look?
You will need to set border, box-shadow and background to 0/none to remove any greyish appearance as seen on button. Then to remove the rounded corners set border-radius to 0px.
Rules are :
input[type="submit"]
/* Or better yet try giving an ID or class if possible*/
{
border: 0;
background: none;
box-shadow: none;
border-radius: 0px;
}
outline: none; would be my first guess.
And also you would probably want to remove the :focus state and :hover state as so
input[type="submit"]:focus {
background:none;
outline: none;
border:none;
}
input[type="submit"]:hover {
background: none;
border: none;
outline: none;
box-shadow: none;
}
this makes it so when it is pressed, it won't have an emphasized outline.
if it doesn't work try removing other styles such as box-shadow:none;, border-radius:none;.
I see that the button corners are rounded. Maybe this is caused by other styles that affecting it. Try to remove the border-radius like this:
input {
border: 0;
border-radius: 0;
background: none;
-webkit-appearance: none;
}
If that didn't solve the issue, then you need to check what style that is adding the top border. You can try using CSS !important with the border declaration(not recommended btw) :
input {
border: 0 !important;
border-radius: 0;
background: none;
-webkit-appearance: none;
}
input {
border: 0 none hlsa(0,0%,0%,0);
outline: 0 none hlsa(0,0%,0%,0);
box-shadow: none;
background: none;
-webkit-appearance: none;
}
Even though outline isn't a browser default (AFAIK), in Bootstrap (if your'e using it or another simular framework) outline is applied even though it's not showing in computed style. I'm still looking for that question concerning that. Btw, I didn't add border-radius because I figure you might want rounded corners, and it shouldn't be a problem.

Input default CSS

http://jsfiddle.net/fj5u5Lk3/
<input type="text"></input>
On focus, this field gets a blue border, by default. Where can I find the default value and color code of it? I want to add my own, but it gets overwritten. I want to remove it, but then want to add it back on, and can't without knowing the default values.
You can use input[type="text"]:focus:
input[type="text"]:focus {
outline: none;
box-shadow: 0px 0px 5px #61C5FA;
border:1px solid #5AB0DB;
}
input[type="text"]:focus:hover {
outline: none;
box-shadow: 0px 0px 5px #61C5FA;
border:1px solid #5AB0DB;
border-radius:0;
}
<input type="text"></input>
It's called outline property. You can set
outline: 0px;
to disable it. And, for example
p {
outline-style: dotted;
outline-color: #00ff00;
}
for some properties. You can read something here: http://www.w3schools.com/cssref/pr_outline-color.asp or just search "outline css property"
from W3Schools :
Focused Inputs
By default, some browsers will add a blue outline around the input when it gets focus (clicked on). You can remove this behavior by adding outline: none; to the input.

Border radius on Focus input field

how can we adjust the border radius of the input field focus.
HTML
<input type="text" class="rest" />
CSS
.rest{border-radius:15px;border:1px solid red;}
Removed the standard outline (which does not accept border-radius) and used a blue box-shadow instead:
.rest{
border-radius: 15px;
border: 1px solid grey;
padding-left: 8px;
}
.rest:focus {
outline: none;
box-shadow: 0px 0px 2px #0066ff;
}
<input type="text" class="rest" />
codepen demo
use the :focus pseudo selector
.rest:focus{
border-radius:0;
}
DEMO
You have to disable the outline of the element focus state:
*:focus { /*OR .rest:focus*/
outline:none;
}
Here is a FIDDLE
If you want the border-radius on the browser default focus outline you can do it only on firefox with -moz-outline-border:5px; , but this will only work on FF, however the request to implement a similar feature in WebKit was closed as WONTFIX, The plan for the future is to make the outlines follow the borders.
The other answers have covered the solution, however, the supplied CSS styles do not accurately reproduce the blue ring color or size. For example, replacing:
:focus {
outline: -webkit-focus-ring-color auto 5px;
}
With the solutions provided, results in a purple-tinted blue
before and after pic. Instead, try this color:
.rest:focus {
outline: none;
border-radius: 8px; /* Your border radius here */
box-shadow: 0px 0px 1px rgba(0,100,255,1),
0px 0px 2px rgba(0,100,255,1),
0px 0px 3px rgba(0,100,255,1); /* #0064FF */
}
Removing the default outline when input is in focus and adding a border that should match the border radius of the default state of input
.rest:focus {
outline: none;
border: 1px blue solid;
}

How come I can't remove the blue textarea border in Twitter Bootstrap?

In Chrome, there is a blue border around the textarea.
How come I can't remove it?
textarea:hover, input:hover, textarea:active, input:active, textarea:focus, input:focus {
outline:0px !important;
}
You have write -webkit-appearance:none; like this:
textarea:hover,
input:hover,
textarea:active,
input:active,
textarea:focus,
input:focus,
button:focus,
button:active,
button:hover,
label:focus,
.btn:active,
.btn.active
{
outline:0px !important;
-webkit-appearance:none;
box-shadow: none !important;
}
Bootstrap 3
If you just want to change the color, change the variable (recommended):
Less or Customizer
#input-border-focus: red;
variables.less
Sass
$input-border-focus: red;
variables.sass
If you wan't to remove it completely, you'll have to overwrite the Mixin that sets the outline.
.form-control-focus(#color: #input-border-focus) {}
CSS
If you are using css overwrite it via:
.form-control:focus{
border-color: #cccccc;
-webkit-box-shadow: none;
box-shadow: none;
}
Link to implementation
I believe that's a shadow. Try this:
.box-shadow(none);
Or if you're not using LESS:
box-shadow: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
try this, I think this will help and your blue border will be removed:
outline:none;
This worked for me
.form-control {
box-shadow: none!important;}
This works 100%.
textarea:focus, input[type="text"]:focus,textarea[type="text"]:focus, input[type="password"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="date"]:focus, input[type="month"]:focus, input[type="time"]:focus, input[type="week"]:focus, input[type="number"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="color"]:focus, .uneditable-input:focus, .form-control:focus {
border-color: (your color) or none;
box-shadow:(your color) or none;
outline: (your color) or none;}
Bootstrap 4.0
*:focus
{
box-shadow: none !important;
border: solid 1px red( any color ) !important;
}
visual example
Try this change border-color to anything which you want
.form-control:focus {
border-color: #666666;
-webkit-box-shadow: none;
box-shadow: none;
}
BOOTSTRAP 4
If you do not want to kill a fly with bazooka by use -webkit-appearance:none; which also kills nice sliderinputs btw and presuming you are working with the bootstrap form css selector "form-control" for your input.
This is the solution:
.form-control:focus {
box-shadow: none!important;
border-color: #ced4da!important;
}
If you want to keep a tiny small blue outline the leave border-color out.
If you are someone, who still face this issue.
Here is the answer, thanks god.
.radio-custom input[type=radio]:focus+label::before {
background-image: none !important;
outline: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
}
You are wondering why others solution doesn't works for you.
Because the style wasn't actually applied to radio button.
Add this style you will find your answer
input[type="text"] {
margin-left: 10px;
}
label::before thats where you have to apply your style.
This is what worked for me.. All the other solutions didn't quite work for me, but I understood one thing from the other solutions and its that default styles of textarea and label in combination is responsible for the blue border.
textarea, label
{
outline:0px !important;
-webkit-box-shadow: none !important;
}
EDIT: I had this issue with Ant Design textarea. Thats why this solution worked for me. So, if you are using Ant, then use this.
For future reference you can work out computed styles via an inspector
Use outline: transparent; in order to make the outline appear like it isn't there but still provide accessibility to your forms. outline: none; will negatively impact accessibility.
Source: http://outlinenone.com/
Your best bet is to right click > inspect the element.
I am using Bootstrap 4 and none of the suggestions worked until I did this.
Once I found where the relevant code was in the inspect window, I copied and pasted the relevant code that was causing the :focus to be outlined blue and changed it accordingly.
This is the code that worked in my css
.btn.focus, .btn:focus
{
outline: 0;
box-shadow: 0 0 0 0;
}
This worked for me
input[type=text]:focus{outline: none;}
i'm using bootstrap 3
Solved using this. Works fine on bootstrap 3.x and 4.0
* {
outline:0px !important;
-webkit-appearance:none;
}
With this code, you're going to remove outline from all tags and classes.
textarea:hover,
input:hover,
textarea:active,
input:active,
textarea:focus,
input:focus
{
outline: 0px !important;
border: none!important;
}
*use border:none; instead of outline because the focus line is a border not a outline.
For anyone still searching. It's neither border or box-shadow. It's actually "outline". So just set outline: none; to disable it.
.was-validated .form-control:valid,
.was-validated .form-control:invalid {
background-image: none;
box-shadow: none;
}
.was-validated .form-control:invalid:focus,
.was-validated .form-control:valid {
box-shadow: none;
}
.form-control:focus {
outline: none;
box-shadow: none;
}