title: Define width of div in HTML (set max-width)
body: <p>This should be so easy, but I just cannot get it to work.</p>
  
  <p>I have a div that will contain a kind of tooltip on a Google map (an implementation of google.maps.OverlayView). The amount of text to be displayed is variable. It could be a single (short) word or several sentences. The width of the div should be at most, say, 150px. If the whole text needs less than 150px to display (on a single line), the div should be only as small (ie as wide) as needed. Longer text should be broken into several lines, the div being at most 150px wide.</p>
  
  <p>I thought all that needed to be done (in the css) would be to set "max-width: 150px;". But this does not do what I want (I am testing in IE8): The text gets line-broken <strong>at every white space</strong> (!!) and the div ends up smaller than 150px wide. (When I set "width: 150px;" the div gets wider than I want when the text is short.)</p>
  
  <p>Why does the text (when longer) not fill the max-width, but get broken up far too often? ("Playing around" with word-wrap or text-wrap did not help.)</p>
  
  <p>Is it possible to say: Keep the div as narrow as possible if text fits on one line, and otherwise, don't make it wider than 150px?</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks for the answers / comments, but my problem remains.</p>
  
  <p>My CSS, unspectacularyl, looks like this:</p>
  
  <pre><code>.TTWayPoint {
      max-width:      150px;
      border:         1px solid black;
      padding:        3px;
      background-color:   lightyellow;
      font:           8pt Verdana, Tahoma, "Microsoft Sans Serif", sans-serif;
  }
  </code></pre>
  
  <p>The problem is that longer text gets broken (line wrapped) at every whitespace, i.e. does not fill the max-width. Playing with the display property has not helped.</p>
  
  <p>It seems to me that this is an IE8 issue. (I am actually developping a VB.NET application having a Webbrowser control; AFAIK that means that you are using the version of IE installed on your system, which in my case is IE8 (can't be updated on XP).)</p>