Jump to content

Styling form elements! Help!


sturgess1987

Recommended Posts

Hi everyone!,

 

OK heres the question, i have created my form, and i want it so that when i click on say the textarea, the colour of the textarea will change as will the border colour. I have a feeling it is quite simple, but just cant get my head round it!

 

Heres the code for my form:

<form action="process_article.php" method="post" enctype="multipart/form-data" name="uploadform" id="uploadform">
     
                  <label>
                   Article content:
                  <textarea name="content"  cols="70" rows="10"></textarea>
                
</label>
                  
<label>
                  Tag this article:
                  <input type="text" name="tags" id="tags" size="28"/>
    </label>
                (seperate tags with commas)
    
  </form>

 

I would like to avoid using javascript to achieve this, any ideas?

 

----------------

Now playing: Kinks - Tired Of Waiting For You

via FoxyTunes

Link to comment
Share on other sites

There isn't anything wrong with using Javasript for something like this, its one of those extra features users with scripting enabled will benefit from, not having scripting enabled will simply render the normal textarea.

 

I would only avoid using javascript for layout purposes, I.e rounded corners and such. But extra functionality would only be nice. All through such a behaviour is more or less useless, and might even annoy some users.

 

However, the feature you are looking for is the CSS focus pseudo class, see below.

textarea:focus { background-color: blue; }

Which works in most browsers.

 

 

You should also avoid wrapping the labels around the input fields.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.