title: Why does unitless line-height behave differently from percentage or em in this example?
body: <p>I'm perplexed by the behavior of the following CSS, also illustrated <a href="http://jsfiddle.net/Y7Jta/3/">in this fiddle</a>.</p>
  
  <pre><code>&lt;style type="text/css"&gt;
  p {
      font-size: 14px;
  }
  
  .percentage {
      line-height: 150%;
  }
  
  .em-and-a-half {
      line-height: 1.5em;
  }
  
  .decimal {
      line-height: 1.5;
  }
  
  .smaller {
      font-size:50%;
  }
  
  .caption {
      font-weight: bolder;
      font-size: 80%;
  }
  
  &lt;/style&gt;
  
  &lt;p class="caption"&gt;default line spacing&lt;/p&gt;
  
  &lt;p&gt;This tutorial provides a brief introduction to the
  programming &lt;span class=""&gt;language&lt;/span&gt; by using one of its picture-drawing
  libraries. This tutorial provides a brief introduction to the programming language. This tutorial provides a brief introduction to the programming language.&lt;/p&gt;
  
  &lt;p&gt;This tutorial provides a brief introduction to the
  programming &lt;span class="smaller"&gt;language&lt;/span&gt; by using one of its picture-drawing
  libraries. This tutorial provides a brief introduction to the programming language. This tutorial provides a brief introduction to the programming language.&lt;/p&gt;
  
  
  &lt;p class="caption"&gt;line-height: 150%&lt;/p&gt;
  
  &lt;p class="percentage"&gt;This tutorial provides a brief introduction to the
  programming &lt;span class=""&gt;language&lt;/span&gt; by using one of its picture-drawing
  libraries. This tutorial provides a brief introduction to the programming language. This tutorial provides a brief introduction to the programming language.&lt;/p&gt;
  
  &lt;p class="percentage"&gt;This tutorial provides a brief introduction to the
  programming &lt;span class="smaller"&gt;language&lt;/span&gt; by using one of its picture-drawing
  libraries. This tutorial provides a brief introduction to the programming language. This tutorial provides a brief introduction to the programming language.&lt;/p&gt;
  
  
  &lt;p class="caption"&gt;line-height: 1.5em&lt;/p&gt;
  
  &lt;p class="em-and-a-half"&gt;This tutorial provides a brief introduction to the
  programming &lt;span class=""&gt;language&lt;/span&gt; by using one of its picture-drawing
  libraries. This tutorial provides a brief introduction to the programming language. This tutorial provides a brief introduction to the programming language.&lt;/p&gt;
  
  &lt;p class="em-and-a-half"&gt;This tutorial provides a brief introduction to the
  programming &lt;span class="smaller"&gt;language&lt;/span&gt; by using one of its picture-drawing
  libraries. This tutorial provides a brief introduction to the programming language. This tutorial provides a brief introduction to the programming language.&lt;/p&gt;
  
  
  &lt;p class="caption"&gt;line-height: 1.5&lt;/p&gt;
  
  &lt;p class="decimal"&gt;This tutorial provides a brief introduction to the
  programming &lt;span class=""&gt;language&lt;/span&gt; by using one of its picture-drawing
  libraries. This tutorial provides a brief introduction to the programming language. This tutorial provides a brief introduction to the programming language.&lt;/p&gt;
  
  &lt;p class="decimal"&gt;This tutorial provides a brief introduction to the
  programming &lt;span class="smaller"&gt;language&lt;/span&gt; by using one of its picture-drawing
  libraries. This tutorial provides a brief introduction to the programming language. This tutorial provides a brief introduction to the programming language.&lt;/p&gt;
  </code></pre>
  
  <p>The first two paragraphs have default line spacing. The second paragraph has one word that is smaller. But it doesn't affect the line spacing in that paragraph. Not that it should, but then —</p>
  
  <p>The next two paragraphs have <code>line-height: 150%</code>. Again, the second paragraph has one word that's smaller. But this time, for reasons unclear, the smaller font creates extra space between the first two lines (at least in Safari, Chrome, Firefox and Explorer). This is the original problem in my CSS that I was trying to fix. (I speculate that it has something to do with the browser shrinking the word and then shifting it downward vertically to realign the baselines.)</p>
  
  <p>The next two paragraphs have <code>line-height: 1.5em</code>. My understanding is that <code>1.5em</code> is the same as <code>150%</code>. And indeed, the behavior is the same: extra space between the first two lines of the second paragraph.</p>
  
  <p><strong>But here's where it gets weird</strong>: the next two paragraphs have <code>line-height: 1.5</code> — no unit specified. This time, the extra-space problem disappears.</p>
  
  <p><a href="https://i.stack.imgur.com/6bJu2.png"><img src="https://i.stack.imgur.com/6bJu2.png" width="124" height="152"></a></p>
  
  <p>In sum, CSS seems to be giving consistent line-spacing results when the line heights of the parent &amp; child are different (through inheritance of the unitless value) but inconsistent results when the line heights of the parent &amp; child are the same. </p>
  
  <p>Thus my questions: </p>
  
  <ol>
  <li><p>I know there's an intentional semantic difference <a href="http://www.w3.org/TR/2011/PR-CSS2-20110412/visudet.html#propdef-line-height">in the CSS spec</a> between <code>1.5</code> and <code>150%</code> or its synonym, <code>1.5em</code>. (Namely: a unitless value is passed to the child element and its line height is calculated using the child's font size, whereas a percentage or em value will cause a line height to be calculated for the parent, and then that calculated value is passed to the child.) But how does this account for the difference in behavior seen here? Where is the extra space coming from? If it's a consequence of some CSS positioning rule, then what is that rule?</p></li>
  <li><p>Or, if these examples should all render the same way, then which one is implemented incorrectly? (Note on Q2: The fact that the rendering quirk happens the same way across different browsers strongly suggests that none of them are implemented incorrectly, which will take you back to question (1).)</p></li>
  <li><p><strike>In practical terms, is there a downside to switching to unitless measurements like <code>1.5</code> for <code>line-height</code>?</strike> (Answer: no)</p></li>
  </ol>