7

Possible Duplicate:
Not enforcing fixed width font family

For monospaced text there is no generic font family in the font stack. This causes problems if a user prefers to resort to the browser standard fonts.

Fix: Add a ,monospace, serif at the end of the font stack for monospaced text, per this article. According to the piece, closing the font chain in such a way:

span {font-family: "Courier New", monospace, serif; font-size: 1em;}

<p>This is a 'p' with a <span>'span'</span> inside.</p>

This time around, the answer is: “It depends, but given browser defaults, 16px.”

Really! Even in Safari! And in all tested browsers, it falls back to a generic monospace font at the requested size even if the specific family (or families) we declare aren’t available! This can be verified by altering the specific font family to something that doesn’t actually exist ...

9
  • 1
    Duplicate, and [status-declined]: meta.stackexchange.com/questions/33945/…
    – John Rudy
    Mar 6, 2010 at 19:25
  • 1
    After digging into this a little deeper: There is a simple proven solution. Eric Meyer has published an excellent article about it just a few days ago. While the solution is not new (Wikipedia using it for a least 14month now) Eric has done incredible work in verifying it. meyerweb.com/eric/thoughts/2010/02/12/fixed-monospace-sizing While I can absolutely sympathize with Jeff when he says he's not willingly to go back to the font-family: monospace hell I still think this solution should also be deployed on SO and sisters. Mar 7, 2010 at 10:31
  • 2
    Voted for reopen because: "Not enforcing fixed width font family" proposes the fontstack to be just monospace. I propose something completely different, so it's not a duplicate. My suggestion will solve the Safari problem and will allow people to force a different monospace font in their browsers if they want. Please read the comments for "Not enforcing fixed width font family" Mar 8, 2010 at 21:08
  • 1
    @user0x36E0: Except these are two different questions - the other wants just font-family: monospace so he doesn't have to do any work to use his pet monospaced font. This request fixes some odd sizing issues under certain conditions - which could result in various UI oddities.
    – AnonJr
    Mar 9, 2010 at 14:24
  • @AnonJr: "This request fixes some odd sizing issues under certain conditions - which could result in various UI oddities." Not exactly: The current font stack has no sizing issues, but a usability issue for people on certain platforms. I've got a notion that the other question was closed under the assumption that you can't solve both problems at the same time. That's where I disagree and that's the point I want to get across. If it's still declined for another reason, I will shut up;-) Mar 9, 2010 at 18:04
  • 2
    This was closed prior to the solution being different, and the comment with the article you linked to. While the reasoning was different, the initial close happened while you were proposing strictly monospace as the closing font in the chain. Currently your new setup has this being monospace, serif; based on the article, I'll vote to reopen.
    – John Rudy
    Mar 9, 2010 at 23:40
  • @user0x36E0 The original question was about adding monospace to the existing font stack, not strictly monospace. I learned that solely monospace causes problems, hence the change to monospace, serif Mar 10, 2010 at 18:19
  • 2
    Can someone reopen this? The answer was changed substantially and I don't like to see "status-complete" along with "exact duplicate"
    – Earlz
    Mar 18, 2010 at 15:23
  • 1
    @earlz: especially since its been noted that it is not an exact duplicate...
    – AnonJr
    Mar 19, 2010 at 18:30

0

Browse other questions tagged .