跳到主要内容

Elements Outline

Question

"What I want to ask is, does this outline CSS style apply to all HTML elements? Or is it only applicable to elements like input/button that have actual focus/click interactions with users?"

Answer

The outline CSS property primarily affects form elements and links when they receive focus, typically through keyboard navigation, clicking, or tapping. The main elements that receive a visible outline on focus are form fields (input, textarea, select), buttons (button, submit), and links (a).

However, technically, any element can have the outline property applied to it in CSS and any element can be made focusable by adding a tabindex attribute. Still, in practice, outline is most commonly associated with elements that have interactive or focusable behavior.