Question
I am styling native HTML <button> elements with custom CSS and removing their default border using border: none;.
This works as expected in Safari, but in Chrome, after I click a button, a blue outline or border appears around it. I want the button to keep its custom appearance even after being clicked.
I tried rules like these, but they do not seem to solve the issue:
button:active {
outline: none;
}
button:focus {
outline: none;
}
Here is the CSS I am using:
button.launch {
background-color: #F9A300;
border: none;
height: 40px;
padding: 5px 15px;
color: #ffffff;
font-size: 16px;
font-weight: 300;
margin-top: 10px;
margin-right: 10px;
}
button.launch:hover {
cursor: pointer;
background-color: #FABD44;
}
button.change {
background-color: #F88F00;
border: none;
height: 40px;
padding: 5px 15px;
color: #ffffff;
font-size: 16px;
font-weight: 300;
margin-top: 10px;
margin-right: 10px;
}
button.change:hover {
cursor: pointer;
background-color: #F89900;
}
button:active {
outline: none;
border: none;
}
Why does Chrome show this blue border, and what is the correct way to remove or restyle it?
Short Answer
By the end of this page, you will understand why Chrome shows a blue focus outline on buttons, the difference between :active and :focus, how to remove or customize focus styles with CSS, and why accessibility matters when changing default browser button behavior.
Concept
Browsers add default styles to form controls like <button>, <input>, and <select>. One of those styles is the focus outline.
When a button receives focus—usually after a click, keyboard navigation, or script interaction—the browser may draw an outline around it. In Chrome, this often appears as a blue ring or border.
This is not the same thing as the regular CSS border property. Even if you write:
button {
border: none;
}
Chrome can still draw a focus outline, because outline is a separate visual property.
A key part of this question is understanding the difference between button states:
:hover— when the mouse is over the element:active— while the element is being pressed:focus— when the element has keyboard or click focus
The blue ring in Chrome is usually caused by :focus, not :active.
Why this matters:
- Focus styles help keyboard users know where they are on the page.
- Removing focus styles completely can make a site harder or impossible to use for accessibility.
Mental Model
Think of a button as an object with several visual modes:
- Normal: sitting still
- Hover: the mouse is pointing at it
- Active: you are currently pressing it
- Focus: the button is selected and ready to respond to keyboard input
The blue border is like a highlight marker the browser adds to say, “this button is currently selected.”
Removing the border with border: none is like removing the frame from a picture. The focus outline is a separate highlighter drawn around the picture, so removing the frame does not remove the highlight.
Syntax and Examples
The core CSS selector for this issue is :focus.
button:focus {
outline: none;
}
A more complete example:
button {
background-color: orange;
border: none;
color: white;
padding: 10px 16px;
}
button:focus {
outline: none;
}
This removes the browser's default focus outline.
However, an accessible version is better:
button {
background-color: orange;
border: none;
color: white;
padding: 10px 16px;
}
button:focus {
outline: 2px solid #333;
outline-offset: 2px;
}
This replaces the blue browser outline with a custom one.
For modern browsers, :focus-visible is often the best choice:
Step by Step Execution
Consider this example:
<button class="launch">Launch</button>
button.launch {
background-color: #F9A300;
border: none;
color: white;
padding: 10px 16px;
}
button.launch:focus {
outline: none;
}
What happens step by step:
-
The page loads.
- The button gets its normal styles.
- It has no visible border because of
border: none.
-
The user moves the mouse over the button.
- If a
:hoverrule exists, that style applies.
- If a
-
The user clicks the button.
- During the press,
:activemay apply briefly. - Chrome may also give the button focus.
- During the press,
-
Once the click finishes, stops applying.
Real World Use Cases
Customizing button focus states appears in many real projects:
- Design systems: teams want all buttons to match a consistent brand style.
- Admin dashboards: buttons for save, delete, and update actions often need custom hover and focus states.
- Landing pages: marketing pages commonly use heavily styled CTA buttons.
- Mobile-friendly UIs: developers remove inconsistent browser defaults and replace them with controlled styles.
- Accessibility improvements: rather than using the browser default, teams create a clearer, higher-contrast focus ring.
Examples:
- A checkout button may use a bright custom outline to make keyboard navigation obvious.
- A dashboard may define one shared
.btn:focus-visiblerule for all reusable button components. - A form submit button might keep a focus ring for keyboard users but hide it for mouse clicks using
:focus-visible.
Real Codebase Usage
In real codebases, developers usually do not style every button from scratch each time. Instead, they create shared button classes and define states consistently.
Common patterns include:
Shared base button class
.btn {
border: none;
padding: 10px 16px;
cursor: pointer;
}
.btn:focus-visible {
outline: 2px solid #1d4ed8;
outline-offset: 2px;
}
Then variant classes add color:
.btn-primary {
background: #f9a300;
color: white;
}
.btn-secondary {
background: #f88f00;
color: white;
}
Accessibility-first focus handling
Instead of removing focus entirely:
.btn:focus {
outline: none;
}
.btn:focus-visible {
outline: solid ;
}
Common Mistakes
1. Styling :active instead of :focus
Broken idea:
button:active {
outline: none;
}
Why it fails:
:activeonly applies while the mouse button is being pressed.- The blue border usually appears because the button remains focused afterward.
Use this instead:
button:focus {
outline: none;
}
2. Confusing border with outline
Broken idea:
button {
border: none;
}
Why it fails:
- The browser focus ring is often an
outline, not a border.
3. Removing focus styles completely
This works visually, but hurts usability:
Comparisons
| Concept | What it means | When it applies | Good for this problem? |
|---|---|---|---|
border | The element's normal box border | Always, if set | No, not enough |
outline | A line drawn outside the border | Often used for focus | Yes |
:hover | Mouse pointer is over the element | While hovering | No |
:active | Element is being pressed | During click/press only | Usually no |
:focus | Element currently has focus | After click, tab, or script focus |
Cheat Sheet
/* Remove default focus ring */
button:focus {
outline: none;
}
/* Better: add your own focus style */
button:focus {
outline: 2px solid #333;
outline-offset: 2px;
}
/* Modern approach */
button:focus {
outline: none;
}
button:focus-visible {
outline: 2px solid #333;
outline-offset: 2px;
}
Quick rules:
borderandoutlineare different.- Chrome's blue ring is usually a focus outline.
:activeis temporary.:focusoften remains after clicking.:focus-visibleis best for accessible custom focus styling.- Do not remove focus styles without providing a visible replacement.
Useful pattern:
{
: none;
}
{
: none;
}
{
: solid ;
: ;
}
FAQ
Why does Chrome show a blue outline on buttons?
Chrome adds a default focus outline to buttons when they receive focus. This helps users see which element is currently selected.
Why did button:active not remove the blue border?
Because :active only applies while the button is being pressed. The blue ring usually appears due to :focus, which remains after the click.
Is border: none enough to remove the blue border?
No. The blue ring is usually an outline, not a border.
Should I use outline: none on buttons?
Only if you replace it with another visible focus style. Completely removing focus indicators can hurt accessibility.
What is the difference between :focus and :focus-visible?
:focus matches any focused element. :focus-visible usually shows styles only when the browser decides focus should be visibly indicated, often for keyboard users.
How do I make button focus styles look consistent across browsers?
Define your own :focus or styles instead of relying on browser defaults.
Mini Project
Description
Build a small button style demo that shows the difference between normal, hover, focus, and custom focus-visible states. This helps you understand how browsers style buttons and how to replace the default Chrome focus ring with your own accessible design.
Goal
Create two custom-styled buttons that keep a clean design while still showing a clear, custom focus state.
Requirements
- Create two HTML
<button>elements with different classes. - Remove the default button border in CSS.
- Add a hover style for each button.
- Add a custom visible focus style using
:focus-visible. - Keep the buttons accessible by not removing focus indication entirely.
Keep learning
Related questions
Angular ngClass Conditional Class Binding Explained
Learn how to use Angular ngClass for conditional classes, fix common binding mistakes, and understand why this template error happens.
CSS :not() Selector for Elements Without a Class or Attribute
Learn how to use the CSS :not() selector to target elements that do not have a specific class or attribute, with examples and common pitfalls.
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.