Home >Web Front-end >CSS Tutorial >How to Remove or Customize Focus Highlights on Input Text Elements?
Eliminating Border Highlights in Input Text Elements
When an input text element receives focus, browsers like Safari and Chrome tend to display a distracting blue border around it. This can be undesirable for certain layouts.
Customizing Firefox Behavior
In Firefox, you can control the border appearance using the "border" property. However, other browsers may not support this approach.
Removing the Focus Outline in Safari
To remove the border highlight in Safari, you can use the "outline-width" property:
input.middle:focus { outline-width: 0; }
For all basic form elements:
input:focus, select:focus, textarea:focus, button:focus { outline: none; }
Supporting Content-Editable Elements
To also include elements with the "contenteditable" attribute set to true:
[contenteditable="true"]:focus { outline: none; }
Disabling Focus Outlines Completely
As a last resort, you can disable focus outlines for all elements:
*:focus { outline: none; }
Accessibility Considerations
Note that focus outlines enhance accessibility by indicating the active element. Consider alternative methods for providing focus visibility before disabling them entirely.
The above is the detailed content of How to Remove or Customize Focus Highlights on Input Text Elements?. For more information, please follow other related articles on the PHP Chinese website!