Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've deduced that the main trouble is the <code>line-height</code> property.</p> <p>Both browsers attempt to vertically center all text on buttons. In combination with the <code>height</code> property, however, if there is not enough room to render the full standard line-height (glyph padding grows quite large with large font sizes), both browsers will pin the glyph to the top of the button, trimming the bottom.</p> <p>Normally, the <code>line-height</code> would help adjust this, and in Chrome, in your example, this was successful. However, in the case of <code>button</code> and <code>input type="submit"</code> elements, Firefox ignores <strong>line-height</strong> altogether, so it can't be used in this way to "fix" the positioning of the character. Using the extreme example below, we can see that the text has been pushed out of visbility in Chrome, while it still stays right in the (vertical) center in Firefox.</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;body&gt; &lt;style type="text/css"&gt; input { border:1px solid black; line-height:1000px; height:40px; } &lt;/style&gt; &lt;input type="submit" value="Test"/&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>Firefox</strong>: <img src="https://i.stack.imgur.com/fCh6Z.png" alt="Firefox"> <strong>Chrome</strong>: <img src="https://i.stack.imgur.com/UGPFO.png" alt="Chrome"></p> <p>When a button element is left to the native style (remove the <code>border</code>), <code>line-height</code> is ignored by both browsers (weirdly, Chrome also ignores the height but Firefox does not). As soon as the button is custom-styled, Chrome picks up the <code>line-height</code> but Firefox does not.</p> <hr> <p><strong>So what can you do?</strong></p> <p>If you still want to make use of CSS fonts...</p> <ol> <li>First of all, make sure your font renders the glyphs in the same vertical-alignment that a standard font displays a basic full-height character, like <code>H</code>. <em>(It appears you've done this for the most part, since your page looks significantly better than the screenshots in the question.)</em></li> <li>Second, you'll notice that if you use a font like Arial, and display an H (at the same font size), it's also low. This is because the <em>built in standard line-height of the font</em> gives it quite a bit of room above the character. This indicates that you may have some success if you can <strong>edit the font to trim this,</strong> thereby giving the character enough room to not be trimmed at the bottom by the browser.</li> <li>Probably less ideal to you, but still an option, you can use other elements, either in combination with or in place of the <code>button/submit</code> element, to get the character into place.</li> </ol> <hr> <p><strong>Alternative option</strong></p> <p>I'm not sure what your goal is in using CSS fonts, but often it is for some form of <em>progressive enhancement/graceful degradation</em>. In this case, although (as you said in the comments) the special character is a standardized Unicode "right-pointing magnifying glass", it still will not have any meaning to the user if it doesn't <em>render.</em></p> <p>Given that the benefit of graceful degradation is to allow simpler technologies to display your website without appearing broken, the use of this character seems suspect &mdash; without CSS fonts or a native font with this character, it will render as &#128269; a <code>?</code>, or simply a blank box.</p> <p>A better option for graceful degradation, given this problem, would be to simply use a <strong>background-image</strong>. Make the text of the button "Search", hide the text (through CSS), and apply the background image, and then you have <em>actual</em> graceful degradation, and a fancy character for better browsers.</p> <p>A background image <em>could</em> also (obviously dependent on the files themselves) have other benefits, such as faster load and render times (for instance, if a developer wanted to use a single character from a full-character-set font).</p>
 

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