Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The computed value of <code>line-height: normal</code> varies between platforms, browsers (and different versions of the same browser, as you state), fonts, and even different sizes of the same font <a href="http://meyerweb.com/eric/thoughts/2008/05/06/line-height-abnormal/" rel="noreferrer">(see Eric Meyer's article)</a>.</p> <p>Setting a unitless value such as... </p> <pre><code>body {line-height: 1.2;} </code></pre> <p>...<em>should</em> work to normalize the spacing between browsers. If this is not working, can you provide a more-detailed description of your stylesheet?</p> <p>It's hard (impossible?) to get "pixel-perfect" results, but in order to get results that are as predictable as possible, I try to use a line height that produces a nice round value when multiplied by the font-size. We can't know the user agent's default font size, but 16 pixels is somewhat common. </p> <pre><code>body { font-size: 100%; line-height: 1.5; } </code></pre> <p>If the user agent's starting font size is indeed 16 pixels then the line height of <code>1.5</code> comes out to a nice, even 24 pixels. Users can and do change the default font size or the page zoom, though, and different browsers have different methods of scaling the page. Nevertheless, I think I've had reasonable success for a majority of the users. If I can't make the line height come out exactly, then I shoot for a little above the integer rather than a little below, because some browsers seem to truncate values rather than round them.</p> <p>Also, note that if you use a percentage for the line height, it behaves differently when the value is inherited. </p> <pre><code>body { font-size: 100%; line-height: 150%; } p { font-size: 75%; } </code></pre> <p>Starting from a base font size of 16 pixels, the line height will be 24 pixels. Within a <code>&lt;p&gt;</code> element the font size becomes 12 pixels, but the line height does <strong>not</strong> become 18 pixels, rather it remains 24 pixels. This is the difference between <code>line-height: 1.5</code> and <code>line-height: 150%</code>. When <code>body {line-height: 1.5;}</code> is used, the line height for <code>&lt;p&gt;</code> <em>is</em> 18 pixels.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload