title: How to detect when multiple lines are occurring in a div?
body: <p>I have a div tag with a specific width that will receive a text through javascript. </p>
  
  <pre><code>&lt;div id="titleTop" style="width:400px; height:25px; padding-top:15px;"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>And whenever the length of that text exceeds the width, the div should adjust its padding, so the 2nd line of the text isn't obscured by the other div positioned below.</p>
  
  <pre><code>if(document.getElementById("titleTop").innerHTML.length &gt;= 70){
  
      document.getElementById("titleTop").style.paddingTop = 5 + "px";
      document.getElementById("titleTop").style.height = 35 + "px";
  }
  </code></pre>
  
  <p>My problem is this method isn't very reliable. Is there any way to detect if the text triggered multiple lines inside the div? Or to have the padding adjust itself proportionately? </p>
  
  <p>EDIT: Just to make things clear, my problem isn't with the height of the div (it has to stay 40px high at all times), but with aligning the text vertically within it</p>