26

Something that's struck me as weird for a long time is that I get a horizontal scrollbar on code samples on Stack Overflow if they go over 79 characters. This seems perverse, given that 80 characters is such a common column limit in coding style guides. It means that there's lots of code out there that, if copied and pasted into a Stack Overflow post, would just barely cause the code snippet to get a horizontal scrollbar on many machines.

Image demonstrating the problem

Is this intentional behaviour? It seems like a bug, as though the CSS has been crafted specifically to try and avoid 80 column code snippets from getting a scrollbar in any common browser, but missed the target in Chrome by a few pixels. This seems especially true given that 80 column snippets don't get a scrollbar in Firefox.

I've observed this in Chrome and Chromium for as long as I can remember (at least the last 6 months or so), and on multiple Ubuntu machines.

The "Rendered Fonts" section of Chrome's dev tools indicates that the font being used is Liberation Mono, although it's worth noting that this version of Liberation Mono clearly differs from that shown on Wikipedia; the zeroes in Wikipedia's version of Liberation Mono have no dots in them, but mine do.

0

1 Answer 1

-1

If I had to guess, I would say that is because you are using a non-standard font. Stack Overflow code blocks use this font stack:

Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif

Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, and Courier New all cross (not dot) or have nothing inside their 0s, and DejaVu Sans Mono and Bitstream Vera Sans Mono do not curve their 7s at all. This means that Chrome displays code blocks in the system monospace or serif font, whatever that is on your computer.

Whoever codes this website isn't going to change widths of things for your weird font, they are going to design it for the 8 different fonts they expect you to use.

2
  • 6
    "your weird font" - it can't be that weird if it's what Chrome and Chromium decide to use here on an ordinary Ubuntu install! Also, according to the inspector, the rendered font is Liberation Mono.
    – Mark Amery
    Commented Dec 20, 2014 at 16:31
  • 1
    I've updated my question with info about the font being used.
    – Mark Amery
    Commented Dec 20, 2014 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .