YouTip LogoYouTip

Sel Focus

## CSS :focus Selector **Definition and Usage** The :focus selector is used to select an element that has focus. This selector is typically used on form elements like input, textarea, and a tags that can get focus. **Version:** CSS2 --- ## Browser Support The numbers in the table indicate the version number of the browser that first fully supports this selector. | Selector | Chrome | IE | Firefox | Safari | Opera | |----------|--------|-----|---------|--------|-------| | :focus | 1.0 | 8.0 | 1.0 | 1.0 | 7.0 | --- ## CSS Syntax ```css :focus { css declarations; } ``` --- ## Example Apply styles when the form input field gets focus: ```html input:focus { background-color: yellow; } First name:
Last name:

Note: Click on the input field to see the effect.

``` --- ## Related Resources (/cssref/css-reference.html) (/cssref/css-selectors.html) (/css3/css3-tutorial.html)
← Sel FirstletterSel Hover β†’