title: How to limit width of <h1> - <h5> tag by length of content
body: <p>Thanks for taking your time for my question. 
  I know, this question has been asked and answered before, but somehow i can't make it look like expected. I will show you below some of the things I've tried. </p>
  
  <p>I have a div with a rounded boarder where i want to display a caption (one of the standard captions  - ). </p>
  
  <p>This is what i've got: </p>
  
  <p>HTML: </p>
  
  <pre><code>&lt;div id="selectModel" class="admin_dropdown"&gt;
     &lt;h5 class="admin_caption"&gt;Wählen sie das anzuzeigende Model&lt;/h5&gt;
     [...]
  &lt;/div&gt;
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>h5.admin_caption {
  
          width: 300px;
          margin-top: -20px;
          margin-left: auto;
          margin-right: auto;
          background: white;
  
      }
  </code></pre>
  
  <p>I am not allowed to post pictures (&lt;10 rep), so I hope jsfiddle works).</p>
  
  <p>How it looks like: <a href="http://jsfiddle.net/vrP39/" rel="nofollow noreferrer">http://jsfiddle.net/vrP39/</a></p>
  
  <p>What i want it to look like: <a href="http://jsfiddle.net/vrP39/1/" rel="nofollow noreferrer">http://jsfiddle.net/vrP39/1/</a></p>
  
  <p>As you can see, the result of the last fiddle is achieved through changing the <code>width</code> until it matches the caption. Of course i want to use it with several captions with different length, so this is not an option. </p>
  
  <p>What i've tried so far: </p>
  
  <ol>
  <li>Using a <code>&lt;span&gt;</code> around the text in my caption, also styling the <code>&lt;span&gt;</code> element instead of the <code>&lt;h5&gt;</code></li>
  <li><code>display: inline-block</code> or <code>display: inline</code></li>
  <li><code>float: left</code> in the <code>&lt;h5&gt;</code> and <code>clear:left</code> in the following element</li>
  </ol>
  
  <p>I saw this post (amongst others) here on stackoverflow (<a href="https://stackoverflow.com/questions/1160759/width-of-headers-h1-h2-etc">Width of Headers (H1, H2 etc)</a>) but nothing that i tried seems to work. </p>
  
  <p>What did i do wrong? Any help is greatly appreciated, thanks in advance!</p>