Solved

Form Field Backgrounds

Posted on 2011-03-14
3
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
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…

726 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