Home >Web Front-end >CSS Tutorial >How Can I Remove the Focus Border from Input Text Elements in Safari and Chrome?
Eliminating Input Text Element Focus Border
When input text elements gain focus, certain browsers, including Safari and Chrome, may display a blue border around them. While this visual cue can be useful for accessibility and usability, it may not always be desirable in specific design layouts.
To remove this border highlight in Safari, utilize CSS:
input.middle:focus { outline-width: 0; }
This targeting allows you to isolate the desired input element with the class "middle." Alternatively, to affect all form elements, use:
input:focus, select:focus, textarea:focus, button:focus { outline: none; }
Noah Whitmore suggests extending this to contenteditable elements:
[contenteditable="true"]:focus { outline: none; }
Ultimately, you could also disable focus outlines on all elements with:
*:focus { outline: none; }
However, this approach is discouraged for accessibility reasons. Remember that the focus outline serves as a helpful indicator for users navigating the interface.
The above is the detailed content of How Can I Remove the Focus Border from Input Text Elements in Safari and Chrome?. For more information, please follow other related articles on the PHP Chinese website!