title: how to set css width equal to length of longest text
body: <p>I have quite a challenging task.</p>
  
  <p>I have this menu here... <a href="http://jsfiddle.net/K2Zzh/6/" rel="noreferrer">http://jsfiddle.net/K2Zzh/6/</a></p>
  
  <p>If you hover over 'treatments', the width for the dropdown menu is set at 150px, which is fine, however, if you hover over 'aftercare', you can see this width is too wide. I have tried min-width, auto, inline-block, but no luck so far.</p>
  
  <p>Rather than creating a separate class for each dropdown, is there a clever way of setting the width to only be as large as the longest text per menu?</p>
  
  <p>The css code i have used for the drop down... </p>
  
  <pre><code>.dropdown ul {
    position: absolute;
    top: 43px;
    z-index: 100;
    border-left: 1px solid #f6634c;
    border-bottom: 1px solid #f6634c;
    border-right: 1px solid #f6634c;
  }
  .dropdown ul li a {
    background-color: #fff;
    width: 150px;
    text-align: left;
  }​
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>My HTML Code... </p>
  
  <pre><code>&lt;ul class="mainNav"&gt;
    &lt;li&gt;&lt;a href=""&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li class="dropdown"&gt;
      &lt;a href=""&gt;Treatments&lt;/a&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=""&gt;Body Treatments&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Make Up&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Skincare&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Hand &amp; Feet Treats&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Hair Removal&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Alternative Therapies&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Eye Enhancements&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href=""&gt;Gallery&lt;/a&gt;&lt;/li&gt;
    &lt;li class="dropdown"&gt;
      &lt;a href=""&gt;Aftercare&lt;/a&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=""&gt;Body&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Make up&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Skin&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=""&gt;Hand&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href=""&gt;Contact&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>