Question
How to Remove Input Focus Outline in CSS (Chrome) and Do It Accessibly
Question
How can I remove the orange or blue focus border around text input boxes in Chrome?
I want to remove the outline that appears when an input is active or focused. My current CSS for the input looks like this:
input {
background-color: transparent;
border: 0 solid;
height: 20px;
width: 160px;
color: #ccc;
}
What CSS should I use to remove that focus outline, and what should I be aware of when doing this?
Short Answer
By the end of this page, you will understand what the browser focus outline is, how to remove it with CSS, and why replacing it with a custom focus style is usually better for accessibility. You will also see practical examples of :focus, outline, and safer ways to style active form fields.
Concept
Browsers add a focus indicator to form elements like input, textarea, and button when the user clicks them or tabs to them with the keyboard. In Chrome, this often appears as a blue or orange glow, border, or outline.
This focus indicator exists for a good reason:
- It shows which element is currently active.
- It helps keyboard users navigate forms.
- It improves usability and accessibility.
If you want to remove the default browser focus style, you usually target the :focus pseudo-class:
input:focus {
outline: none;
}
This tells the browser not to draw the default outline when the input has focus.
However, removing the outline completely can make your form harder to use, especially for:
- keyboard users
- users with vision impairments
- anyone navigating quickly through a form
Because of that, a better approach is often to replace the default outline with your own visible focus style instead of removing it entirely.
For example:
input:focus {
outline: none;
border: 1px solid #4d90fe;
: (, , , );
}
Mental Model
Think of focus like a cursor spotlight on a stage.
When a user clicks or tabs into an input, the browser shines a light on that element so the user knows, "This is where typing will go."
:focusmeans the spotlight is onoutlineis the browser's default spotlight effect- removing it turns the spotlight off
- replacing it gives you your own custom spotlight
So the real question is usually not just, "How do I hide the spotlight?" but also, "What visible cue should I show instead?"
Syntax and Examples
The key selector is :focus.
Remove the default outline
input:focus {
outline: none;
}
This removes the browser's default focus outline.
Full example based on your CSS
input {
background-color: transparent;
border: 0;
height: 20px;
width: 160px;
color: #ccc;
}
input:focus {
outline: none;
}
What this does
inputstyles the normal input stateinput:focusapplies only when the input is activeoutline: none;removes the Chrome focus outline
Better: remove default outline and add your own focus style
input {
background-color: transparent;
: solid ;
: ;
: ;
: ;
: ;
}
{
: none;
: ;
: (, , , );
}
Step by Step Execution
Consider this example:
<input type="text" id="username" placeholder="Username">
input {
border: 1px solid #aaa;
padding: 6px;
}
input:focus {
outline: none;
border-color: blue;
}
Here is what happens step by step:
- The page loads.
- The input is displayed with a gray border because of
border: 1px solid #aaa;. - The user clicks the input or tabs into it.
- The input now matches the
input:focusselector. - The browser applies the focus styles:
outline: none;removes the default focus outlineborder-color: blue;changes the border color to blue
- The user now sees your custom focus style instead of Chrome's default one.
- When the user clicks elsewhere or tabs away, the input loses focus.
- The
:focusstyles stop applying, and the input returns to its normal state.
Real World Use Cases
Focus styling is used in many real interfaces.
Login and signup forms
A focused email or password field should clearly show where the user is typing.
Search bars
A search box often changes border color or glows when active.
Checkout forms
Address, card, and billing fields need strong focus states so users can move through them quickly.
Admin dashboards
Data entry forms often use custom focus styles to match the design system.
Mobile-friendly forms
Even on touch devices, active field styling helps users understand which input is selected.
Design systems
Teams often define one reusable focus style for all interactive components such as:
- inputs
- buttons
- selects
- textareas
- links
Real Codebase Usage
In real projects, developers usually do not remove focus styles globally without replacing them.
Common patterns include:
Custom reusable focus styles
A shared CSS class or component style is often used:
.form-control:focus {
outline: none;
border-color: #2563eb;
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
Design-system consistency
Large codebases often make all interactive elements use the same focus behavior so the UI feels consistent.
Accessibility-first styling
Some teams use :focus-visible so the focus ring appears mainly for keyboard navigation:
input:focus-visible {
outline: 2px solid #2563eb;
outline-offset: 2px;
}
This is useful because:
- mouse users may see less visual noise
- keyboard users still get a clear focus indicator
Common Mistakes
1. Removing focus without adding a replacement
Broken example:
input:focus {
outline: none;
}
Why this is a problem:
- users may not know which field is active
- keyboard navigation becomes harder
Better:
input:focus {
outline: none;
border-color: #4d90fe;
box-shadow: 0 0 0 3px rgba(77, 144, 254, 0.25);
}
2. Styling only input and forgetting other controls
Beginners often style text inputs but forget:
textareaselectbutton
Example:
,
,
,
{
: none;
: (, , , );
}
Comparisons
| Concept | What it does | Affects layout? | Common use |
|---|---|---|---|
outline | Draws a line outside the element | No | Browser focus indicators |
border | Draws around the element box | Yes | Normal element styling |
box-shadow | Adds glow or shadow around the element | No | Custom focus effects |
:focus vs :focus-visible
| Selector | When it applies | Best use |
|---|
Cheat Sheet
/* Remove default focus outline */
input:focus {
outline: none;
}
/* Better: replace it with a custom style */
input:focus {
outline: none;
border-color: #4d90fe;
box-shadow: 0 0 0 3px rgba(77, 144, 254, 0.25);
}
/* Apply to multiple controls */
input:focus,
textarea:focus,
select:focus,
button:focus {
outline: none;
}
/* Keyboard-friendly option */
input:focus-visible {
outline: 2px solid #2563eb;
outline-offset: 2px;
}
Key points:
- Use
:focusto style focused elements. outlineis different from .
FAQ
How do I remove the blue outline from an input in Chrome?
Use the :focus selector and set outline: none;:
input:focus {
outline: none;
}
Why does Chrome show an outline on inputs?
Chrome shows a focus indicator so users can tell which field is active and ready for typing.
Is it bad to remove the input outline?
It can be, if you do not replace it with another visible focus style. Removing it completely can hurt accessibility.
What is the difference between outline and border?
A border is part of the element box and affects layout. An outline is drawn outside the element and usually does not affect layout.
Should I use :focus or :focus-visible?
Use :focus for general focus styling. Use :focus-visible when you want focus indicators to appear mainly during keyboard navigation.
Can I style focused inputs with box-shadow?
Mini Project
Description
Build a small form with a custom focus style for text inputs. This project demonstrates how to remove the browser's default outline and replace it with a clearer, styled focus state that still helps users understand which field is active.
Goal
Create a simple form where focused inputs use a custom border and glow instead of the default browser outline.
Requirements
- Create a form with at least two text inputs.
- Give the inputs a normal default style.
- Add a custom
:focusstyle that removes the default outline. - Make the focused input visibly different from the unfocused one.
- Keep the form usable and easy to understand.
Keep learning
Related questions
CSS Font Scaling Relative to Container Size: %, em, rem, vw, and Responsive Text
Learn how CSS font scaling really works and how to make text responsive using %, em, rem, vw, clamp(), and media queries.
CSS Parent Selector Explained: Selecting a Parent <li> from an <a>
Learn whether CSS has a parent selector, how :has() works, and practical alternatives for styling a parent li from a child anchor.
CSS Previous Sibling Selector: What Exists and How to Work Around It
Learn whether CSS has a previous sibling selector, why it does not, and practical ways to style earlier elements using CSS alternatives.