CSS :focus Selector
ExampleHow to style a text field when it gets focus:
Try it yourself » |
Definition and Usage
The :focus selector styles the element that has focus.
Tip: The :focus selector is allowed on elements that accept keyboard events or other user inputs.
Browser Support
The :focus selector is supported in all major browsers.
Note: For :focus to work in IE, a <!DOCTYPE> must be declared.
CSS Version
The :hover selector was first introduced in:
CSS 1
Related Pages
CSS tutorial: CSS Pseudo classes
Complete CSS Reference