drupal_html_id() alternative for non-Ajax content?
Here's a simpler version I came up with by altering drupal_html_id() that doesn't pay attention to the $ajax_html_ids. Also note that it produces dashes instead of hyphens:

function foo_html_id($id) {
  $id = strtr(drupal_strtolower($id), array(' ' =&gt; '_', '_' =&gt; '_', '[' =&gt; '_', ']' =&gt; ''));
  $id = preg_replace('/[^A-Za-z0-9\-_]/', '', $id);
  $id = preg_replace('/\-+/', '_', $id);

  $seen_ids = &amp;drupal_static(__FUNCTION__);

  if (isset($seen_ids[$id])) {
    $id = $id . '_' . ++$seen_ids[$id];
  }
  else {
    $seen_ids[$id] = 1;
  }

  return $id;
}