Home > Web Front-end > CSS Tutorial > How Can I Remove the Focus Border from Input Text Elements in Safari and Chrome?

How Can I Remove the Focus Border from Input Text Elements in Safari and Chrome?

Mary-Kate Olsen
Release: 2024-12-20 06:31:13
Original
416 people have browsed it

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;
}
Copy after login

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;
}
Copy after login

Noah Whitmore suggests extending this to contenteditable elements:

[contenteditable="true"]:focus {
    outline: none;
}
Copy after login

Ultimately, you could also disable focus outlines on all elements with:

*:focus {
    outline: none;
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template