How can I give option tags of a select tag ids or classes in Drupal 7? I was able to add classes to option tags in a select statement in Drupal 6 using a very convoluted method. I was hoping that there would be a better way in Drupal 7. Does anyone know how to add classes to option tags in select tags?
You cannot give class or an id to options directly through form api. you can however, theme select element to add classes to select options.

   // theme_select
function THEME_select($variables) {
  $element = $variables['element'];
  element_set_attributes($element, array('id', 'name', 'size'));
  _form_set_class($element, array('form-select'));
  return '&lt;select' . drupal_attributes($element['#attributes']) . '&gt;' . THEME_form_select_options($element) . '&lt;/select&gt;';
}

/**
 *
 * @param type $element
 * @param type $choices
 * @return string 
 */
function THEME_form_select_options($element, $choices = NULL) {
  if (!isset($choices)) {
    $choices = $element['#options'];
  }
  // array_key_exists() accommodates the rare event where $element['#value'] is NULL.
  // isset() fails in this situation.
  $value_valid = isset($element['#value']) || array_key_exists('#value', $element);
  $value_is_array = $value_valid &amp;&amp; is_array($element['#value']);
  $options = '';
  foreach ($choices as $key =&gt; $choice) {
    if (is_array($choice)) {
      $options .= '&lt;optgroup label="' . $key . '"&gt;';
      $options .= THEME_form_select_options($element, $choice);
      $options .= '&lt;/optgroup&gt;';
    }
    elseif (is_object($choice)) {
      $options .= THEME_form_select_options($element, $choice-&gt;option);
    }
    else {
      $key = (string) $key;
      if ($value_valid &amp;&amp; (!$value_is_array &amp;&amp; (string) $element['#value'] === $key || ($value_is_array &amp;&amp; in_array($key, $element['#value'])))) {
        $selected = ' selected="selected"';
      }
      else {
        $selected = '';
      }
      $options .= '&lt;option class="' . drupal_clean_css_identifier($key) . '"  value="' . check_plain($key) . '"' . $selected . '&gt;' . check_plain($choice) . '&lt;/option&gt;';
    }
  }
  return $options;
}


Similar question is answered here