How to add css classes to modal forms module My Problem

I'm trying add CSS classes to help me style the modal forms created using the Modal Forms module.

I have a User Login and a User Register form at the moment, but they have no form specific CSS classes. 



Example 1

To style the height of the input boxes:

I either have to use "form-text" in &lt;input&gt; which will edit all form inputs across all forms or "edit-name" which will become "edit-name--1" if the user fails to login and the break the css.

&lt;div class="form-item form-type-textfield form-item-name"&gt;
    &lt;input id="edit-name" class="form-text required" 
    type="text" maxlength="60" size="25" value="" name="name"&gt;
&lt;/div&gt;


Example 2

To alter the labels "username &amp; password" the only tag I can work with is edit-pass

&lt;div class="form-item form-type-password form-item-pass"&gt;
    &lt;label for="edit-pass"&gt;
    ...
&lt;/div&gt;


Which will change edit-pass--x every time they fail to complete the form correctly, resetting the css.

How would I insert CSS classes using hook form alter?

What I've tried

I printed out the array for the user login form (using print_r, can't use dpm because have to be logged in and user login won't work if you're logged in), here's the first chunk of it.

Array ( [name] =&gt; Array ( [#type] =&gt; textfield
                          [#title] =&gt; Username
                          [#size] =&gt; 25
                          [#maxlength] =&gt; 60
                          [#required] =&gt; 1
                          [#description] =&gt; Enter your drupaltest2 username. )

        [pass] =&gt; Array ( [#type] =&gt; password
                          [#title] =&gt; Password
                          [#description] =&gt; Enter the password that accompanies your username.
                          [#required] =&gt; 1 [#size] =&gt; 25 )

        [#validate] =&gt; Array ( [0] =&gt; user_login_name_validate
                               [1] =&gt; user_login_authenticate_validate
                               [2] =&gt; user_login_final_validate )

        [actions] =&gt; Array ( [#type] =&gt; actions
                             [submit] =&gt; Array ( [#type] =&gt; submit
                                                 [#value] =&gt; Log in ) )


I tried inserting

[#class] =&gt; 'TEST';


into [name] and other slight variations but none of them work.  I can give more examples if I've explained this badly.

EDIT -- RajeevK Solution -- Not enough granularity

I added the following lines into my alter form:

Name array:

$form['name'][#prefix] = '&lt;div class = "usernamelogin"&gt;';
$form['name'][#sufix] = '&lt;/div&gt;';


Pass array:

$form['name'][#prefix] = '&lt;div class = "CAPTAINTEST"&gt;';
$form['name'][#sufix] = '&lt;/div&gt;';


And the end results looks like this:



This is what the page looks like (I'm using firebug to show what the div contains).



Or if I select CAPTAINTEST it looks like:



Hopefully this will help some though and cheers to RajeevK for the suggestion. I was hoping to control individual elements of the forms, does anyone know whether it would be possible to get more granularity without having to hack the module?

(Here's my form alter:

function mytheme_form_user_login_alter(&amp;$form, &amp;$form_state, $form_id) {
  //override to change text in user sign in box
  drupal_set_title('');
  $form['name']['#title'] = 'Username/Email';
  $form['name']['#description'] = '';
  $form['name']['#prefix'] = '&lt;div class = "usernamelogin"&gt;';
  $form['name']['#sufix'] = '&lt;/div&gt;';
  $form['pass']['#description'] = '';
  $form['pass']['#prefix'] = '&lt;div class = "CAPTAINTEST"&gt;';
  $form['pass']['#sufix'] = '&lt;/div&gt;';
  $form['actions']['submit']['#value'] = 'Sign In.';
You can use #attributes to add some classes to the elements:

$form['name']['#attributes'] = array('class' =&gt; array('your-class'));


Will output something like this (class added to input element):

&lt;div class="form-item form-type-textfield form-item-name"&gt;
  &lt;label for="edit-name"&gt;Username &lt;span title="This field is required." class="form-required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &lt;input type="text" maxlength="60" size="60" value="" name="name" id="edit-name" class="your-class form-text required"&gt;
  ...
&lt;/div&gt;