title: Make sure string is a valid CSS ID name
body: <p>I have a bunch of database records (without auto_increment IDs or anything else like that) rendered as a list, and it came to pass that I need to differentiate each of them with a unique <code>id</code>.</p>
  
  <p>I could just add a running counter into the loop and be done with it, but unfortunately this ID needs to be cross-referenceable throughout the site, however the list is ordered or filtered.</p>
  
  <p>Therefore I got an idea to include the record title as a part of the <code>id</code> (with a prefix so it doesn't clash with layout elements).</p>
  
  <p>How could I transform a string into an <code>id</code> name in a foolproof way so that it never contains characters that would break the HTML or not work as valid CSS selectors?</p>
  
  <p>For example;</p>
  
  <pre><code>Title ==&gt; prefix_title
  TPS Report 2010 ==&gt; prefix_tps_report_2010
  Mike's "Proposal" ==&gt; prefix_mikes_proposal
  #53: Míguèl ==&gt; prefix_53_miguel
  </code></pre>
  
  <p>The titles are always diverse enough to avoid conflicts, and will never contain any non-western characters.</p>
  
  <p>Thanks!</p>