59

I quite like the look of the font used in the code blocks that appear on Stack Overflow.

What, dear listener, is the font face used for such?

80

It's the first font in the following list that is installed on your system:

  • Consolas
  • Monaco
  • Lucida Console
  • Liberation Mono
  • DejaVu Sans Mono
  • Bitstream Vera Sans Mono
  • Courier New

For more information, look at the CSS file in Firebug.

2
  • 4
    +1 It's good to make the point that it depends on what fonts are installed in the client.
    – pavium
    Jan 19 '10 at 4:53
  • 1
    and the browser defined ones...
    – juanm55
    Jul 9 '12 at 16:34
22
code {
  background-color:#EEEEEE;
  font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New;
}
4
  • 1
    No monospace? I am disappoint.
    – Ignacio Vazquez-Abrams
    Jan 19 '10 at 2:48
  • Edited and fixed ;)
    – schnaader
    Jan 19 '10 at 2:48
  • 2
    @Ignacio: There's a reason monospace isn't used, and that reason is WebKit, which renders it differently than all other browsers.
    – John Rudy
    Jan 19 '10 at 14:40
  • I love it. Snagging this for my site.css.
    – Sam
    Oct 24 '20 at 21:54
7

See Super User:

2
  • 1
    Careful, Arjan, you are currently implying that there would be useful information on SU? That would be shocking!
    – Gnoupi
    Jan 19 '10 at 8:46
  • 3
    @Gnoupi, you know how all the questions that are too difficult for SO are delegated to SU. ;-)
    – Arjan
    Jan 19 '10 at 9:51
7

StackExchange recently changed their code font. The font stack is now different per operating system.

ui-monospace, // San Francisco Mono on macOS and iOS
"Cascadia Mono", "Segoe UI Mono", // Newer Windows monospace fonts that 
                                  // are optionally installed. Most likely 
                                  // to be rendered in Consolas
"Liberation Mono", // Recently updated
Menlo, Monaco, Consolas, // A few sensible system font choices
monospace // The final fallback for rendering in monospace.

See this meta post for more details.

2
  • Aaand this answer is outdated twice already...
    – EvgenKo423
    May 18 at 10:58
  • Updated accordingly, thanks for the heads up! May 18 at 21:44

You must log in to answer this question.