Remove Safari/Chrome textinput/textarea glow

后端 未结 13 938

I am wondering if its possible to remove the default blue and yellow glow when I click on a text input / text area using CSS?

13条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 18:19

    Edit (11 years later): Don't do this unless you're going to provide a fallback to indicate which element is active. Otherwise, this harms accessibility as it essentially removes the indication showing which element in a document has focus. Imagine being a keyboard user and not really knowing what element you can interact with. Let accessibility trump aesthetics here.

    textarea, select, input, button { outline: none; }
    

    Although, it's been argued that keeping the glow/outline is actually beneficial for accessibility as it can help users see which Element is currently focused.

    You can also use the pseudo-element ':focus' to only target the inputs when the user has them selected.

    Demo: https://jsfiddle.net/JohnnyWalkerDesign/xm3zu0cf/

提交回复
热议问题