View Full Version : input:focus question

08-08-2007, 06:51 PM
I have a css page that inside I have this declared

input:focus, textarea:focus, select:focus{

now this places a BG color of any of the fields on the form that have focus to yellow. My question is this: Is there a way to narrow down what types of input fields get the css attribute? For example I have a input type="button" on the page that I don't want to turn yellow onFocus. I only want the input type="text

is there a way to have it do like this
input.text:focus{background:#FFFF00;}(I know this is wrong)

So that all text fields are yellow on focus but not buttons?

Thank you for any help with this.

08-08-2007, 07:03 PM
Look up on CSS 2 selectors.

input[type=button]:focus {Ö}

This does not work in IE 6, though (well, :focus on inputs doesnít work in IE anyway). You could give that button an ID or class to make it backwards compatible.

08-08-2007, 07:06 PM
Thanks. I was hoping to avoid going back and giving ids to all the buttons or text fields as I just wanted a single place to change the style and it update all of that type. And as of now I have many pages with many forms that I would have to change. I was hoping for just controlling a type like input, select but be able to be more specific like your example. Kind of sucks that IE does not support that.

Thanks for your help.