CSS: Field Focus Format
Introduction
Author: Martin WarningYear: 2007
License: Free
This is just a simple CSS code to change the background color of an form input field at the moment the user selects it. We use the CSS focus state to modify the element. This code isn't yet supported by Internet Explorer, but it does work in Firefox.
Code
Languages:- XHTML
- CSS
<input type="text" name="txtName" class="inputtext" size="20" />And the CSS part:
.inputtext{background-color:#eaeaea;}
.inputtext:focus{background-color:#fff;}
The :focus event occurs when a user select the field. It works like the :hover event for the mouseover.
Example: See it in action