Solved

Form Field Backgrounds

Posted on 2011-03-14
3
275 Views
Last Modified: 2012-05-11
I was using this code to highlight the form fields (the colors are not right but not the real issue):
<input type="text" name="sample" onfocus="this.style.backgroundColor='#FFF380'" onblur="this.style.backgroundColor='#ff0000'" />

Open in new window

I had noticed though that when I go to the next form field, the background color still had the highlighted color.

I was completing another form, and that company had the form fields highlighted when I was in that form.  I took a look at their style sheet, and found;
#formbox input:focus {background: #efeff7;}

Open in new window


I looked on IE9, Firefox 3.6, and Opera 11.1 to start off with - and it seems this code has the behavior that I am looking for.

Basically, I am just looking for expert(s) to confirm (or deny) this is better / works well in the browsers, etc.

Thanks!
0
Comment
Question by:coreybryant
3 Comments
 
LVL 9

Accepted Solution

by:
McOz earned 400 total points
ID: 35130217
Yes these are called CSS "psuedo-classes" and are defninitely the way to go. Others include :hover, :active, etc.

Cheers
0
 
LVL 8

Assisted Solution

by:imantas
imantas earned 100 total points
ID: 35130283
McOz is right, but please note that older versions of IE have many problems related to pseudo-classes.
0
 
LVL 29

Author Closing Comment

by:coreybryant
ID: 35130768
Thanks!  That is what I thought, but just wanted to make sure.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now