68

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?

4 Answers 4

82

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
    Commented Jan 19, 2010 at 4:53
  • 2
    and the browser defined ones...
    – juanm55
    Commented Jul 9, 2012 at 16:34
25
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
    Commented Jan 19, 2010 at 2:48
  • Edited and fixed ;)
    – schnaader
    Commented Jan 19, 2010 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
    Commented Jan 19, 2010 at 14:40
  • I love it. Snagging this for my site.css.
    – Sam
    Commented Oct 24, 2020 at 21:54
9

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
    Commented May 18, 2021 at 10:58
  • Updated accordingly, thanks for the heads up! Commented May 18, 2021 at 21:44
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
    Commented Jan 19, 2010 at 8:46
  • 3
    @Gnoupi, you know how all the questions that are too difficult for SO are delegated to SU. ;-)
    – Arjan
    Commented Jan 19, 2010 at 9:51

You must log in to answer this question.