...

View Full Version : input:focus question



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


input:focus, textarea:focus, select:focus{
background:#FFFF00;
}

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.

VIPStephan
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.

tripwater
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum