Reputation: 750
Is it possible to change the properties of a text field when it's selected/active (i.e. being typed in). I'd like to simply change the border colour but I haven't found a thing about actually doing it.
I tried using :active but that only works when the mouse is pressed (obviously I guess)
Upvotes: 2
Views: 3146
Reputation: 29121
To change the border of an input field when it's selected/active, use :focus
Example below:
HTML:
<input type="text" id="ageField" name="age" />
CSS:
#ageField:focus {
border-color: #F00;
}
Explanation / Details @ W3Schools CSS:focus Selector
Upvotes: 1
Reputation: 4423
You are looking for the onFocus/onBlur HTML elements. With these you can use Javascript to modify the colors/style tags.
Upvotes: 0