I am trying to make a custom HTML button element, but chrome highlights it (like above) when it is clicked. How do I prevent this from happening?
Asked
Active
Viewed 1,169 times
3 Answers
1
Solution(s) :-
button:focus {
/** Your CSS styles**/
}
button:active {
/** Your CSS styles**/
}
Explanation(s) :-
The :focus selector is used to select the element that has focus.
Tip: The :focus selector is allowed on elements that accept keyboard events
or other user inputs.
Browser Support
Chrome Safari Firefox Opera IE Android iOS
4+ 3.1+ Any 9.6+ 8+ Any Any
The :active selector is used to select and style the active link.
A link becomes active when you click on it.
Tip: The :active selector can be used on all elements, not only links.
Browser Support
Chrome Safari Firefox Opera IE Android iOS
4+ 3.1+ Any 9.6+ 8+ Any Any
Syntax ::
:focus {
css declarations;
}
:active {
css declarations;
}
Notes And References :-
w3schools Reference (Focus Selector) ::
0
G'day - this is the focus state of the button. You can style it as follows:
button:focus {
outline: none;
/** Any additional styles go here **/
}
For more information on focus take a look at this article from CSS tricks: https://css-tricks.com/almanac/selectors/f/focus/

rhysclay
- 1,645
- 3
- 22
- 42
0
Use this code
a:visited {
outline: 0;
border: 0;
}
See the code for better understanding about button behavior... https://codepen.io/zakirbd/pen/wmxxGX

devzakir
- 387
- 3
- 15
-
Codepen link returns a 404 error – springathing Sep 24 '20 at 17:44