Highlighting form input fields

Discussion in 'HTML' started by Joshua Beall, Apr 6, 2005.

  1. Joshua Beall

    Joshua Beall Guest

    Hi All,

    I've seen on various sites how you can adjust the coloring of form input
    fields (particularly, text inputs and textareas). Here's an example:



    Move the focus to one of the fields and you will see that the background
    color changes.

    How do I do this? Is it possible to do without JS? I've been picking
    through the source and can't seem to isolate it, JS or otherwise. Any tips?

    Joshua Beall, Apr 6, 2005
    1. Advertisements

  2. you can use CSS to do this alas, it only works in better browsers such as
    Firefox, Opera et al.

    input[type="text"]:focus, textarea:focus{
    background: #FFF;
    border-color: #0F0;

    By using input[type="text"]:focus as opposed to just input:focus it stops
    the submit button's appearance from changing, which can look pretty crap.

    You can probably use JS for this as well or Dean Edward's IE7

    Phil Thompson, Apr 8, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.