how can I alter my contact form for adding custom classes
I am using contact form of Drupal 7 core module.
Or you can use hook_form_FORM_ID_alter() to get the specific contact form. hook_form_alter() will run for every form on the page.
function MYMODULE_form_contact_site_form_alter(&$form, &$form_state, $form_id) {
$form['name']['#attributes']['class'] = array('class1', 'class2');
$form['mail']['#attributes']['class'] = array('class1', 'class2');
$form['subject']['#attributes']['class'] = array('class1', 'class2');
$form['message']['#attributes']['class'] = array('class1', 'class2');
// add class to the overall form
$form['#attributes']['class'] = array('class1');
}
If you don't know how to use custom modules, you'd have to research that first. Dropping this function in and replacing MYMODULE with your module name will make this work.
It can been done by $form_id
function MYMODULE_form_alter( &$form, &$form_state, $form_id ) {
if( $form_id == 'contact_site_form' ){
//PUT YOUR STYLING HERE
}
}