Note that there are some explanatory texts on larger screens.

plurals
  1. POWebKit vs Mozilla vertical alignment of font glyphs in box
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/WrMh2.png" alt="Glyphs in Box"></p> <p>This test image shows how wildly different Safari positions text inside a box vs Firefox (Safari 5.0.5 and Firefox 5.0.1 for Mac&nbsp;OS&nbsp;X 10.6.7). Notice how the "S" for <code>sans-serif</code> is butted up to the top of the box in Firefox and not Safari. The difference seem to vary depending on typeface used, where some are even consistently rendered.</p> <p>I've read <a href="https://stackoverflow.com/questions/5880459/vertical-alignment-text-in-container-webkit-vs-firefox/5883303#5883303">people saying</a> that this is because of rounding issues between <code>font-size</code> and <code>line-height</code> (and fixed by setting smaller height than size), but I think that's disproved by my example where sans-serif/helvetica in Firefox always aligns top in the box.</p> <p>To me it looks like Safari gets it more right than Firefox, i.e. text is generally more around a middle line.</p> <p>Is there a good way to get them more consistent? My target is only standards-compliant browsers.</p> <ul> <li>NB1: This has nothing to do with <code>vertical-align</code>.</li> <li>NB2: I investigated a <a href="https://stackoverflow.com/questions/4325440/does-webkit-have-a-clipping-bug/4325791">similar problem in the past</a> with no completely satisfactory outcome.</li> </ul> <p>My test code: <a href="http://jsbin.com/omaboc" rel="nofollow noreferrer">http://jsbin.com/omaboc</a></p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; body { font-size: 50px; line-height: 1em; } div { background: #b5e260; margin-bottom: 5px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div style="font-family: sans-serif"&gt;Some text @ this box&lt;/div&gt; &lt;div style="font-family: serif"&gt;Some text @ this box&lt;/div&gt; &lt;div style="font-family: arial"&gt;Some text @ this box&lt;/div&gt; &lt;div style="font-family: helvetica"&gt;Some text @ this box&lt;/div&gt; &lt;div style="font-family: courier"&gt;Some text @ this box&lt;/div&gt; &lt;div style="font-family: georgia"&gt;Some text @ this box&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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