VOOZH about

URL: https://www.geeksforgeeks.org/css/css-focus-selector/

⇱ CSS :focus Selector - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

CSS :focus Selector

Last Updated : 11 Jul, 2025

The :focus CSS pseudo-class Selector is used to target the focused element ie., it selects an element that is currently focused by the user. This selector works on user input elements, generally used in forms, and is triggered as soon as the user clicks on it or taps on an element, or selects any keyboard events.

Syntax:

:focus {
// CSS property
}

Example: This example illustrates the :focus selector to target the selected element.

Output:

👁 Image

Supported Browsers:

  • Google Chrome 1.0
  • Microsoft Edge 12.0
  • Firefox 1.0
  • Safari 1.0
  • Opera 7.0
Comment
Article Tags: