29

With CSS, if you specify font-family: monospace;, my understanding is that the browser chooses its default/preferred monospaced font.

If that's correct, how can you determine which monospaced font your browser is using?

nickh
  • 4,721
  • 2
  • 29
  • 31

3 Answers3

28

There are 5 generic families that can be used: "serif", "sans-serif", "cursive", "fantasy", and "monospace". When a browser sees one of those, it asks the operating system for the default font in that family.

Thus, which font a web browser uses is OS-dependent.

See Mozilla's documentation on font-family for details.

nickh
  • 4,721
  • 2
  • 29
  • 31
  • 9
    If it is OS dependent, why does the font look different between Chrome and Firefox, on the same OS with the font set to "monospace"? – AncientRo Apr 23 '19 at 10:43
  • 2
    This answer isn’t particularly accurate (and is inaccurate enough that I can’t edit it to correctness without changing its author’s intent). On Linux, browsers probably default to asking fontconfig what “monospace” maps to, but I think other OSes don’t even have the concept of an OS-wide default monospaced font, so browsers have their own defaults. And then users can also customise the defaults—go to your browser’s settings and search for “font” and you’ll find it. So it’s a case of it depending much more on the user-agent than the OS. – Chris Morgan Jan 19 '21 at 13:29
6
  1. Use DevTools
  2. Select HTML element
  3. Search for "Rendered Fonts"

Demo

ynsbl.eng
  • 142
  • 2
  • 8
2

In my case, that was lucida console font. Maybe helps someone)

chavy
  • 841
  • 10
  • 20
  • 3
    Please [edit] your post and include your OS and browser and its version. – Rojo Oct 19 '21 at 18:52
  • TBH, it was a lot of time ago, so, I can't say for sure this information, but at that time I mostly use Windows operation system with Google Chrome browser – chavy Mar 14 '22 at 10:27
  • It is Consolas font in Chrome, Version 111.0.5563.147 (Official Build) (64-bit), 4/3/23. – David Spector Apr 03 '23 at 16:09