9

Depending on the zoom settings I use in Firefox, lines in SO code blocks get scroll bars at different lengths.

Based on a few comments I have read, and also the way that code is formatted, I suspect that my settings are not typical.

That I may format code for optimum legibility for the majority of users, at how many characters does a code line have a scroll bar applied for you?

2
  • 2
    Can you expand on the comments you have read or at least post links of examples problems?
    – jzd
    Commented Mar 8, 2011 at 15:42
  • @jzd a bit late, but for example I had seen comments requesting someone edit a post to eliminate scroll bars, or that they made an edit for that purpose, and it didn't match what I was seeing.
    – Mr.Wizard
    Commented Jun 17, 2012 at 16:41

9 Answers 9

28

Community wiki; please only upvote when the limit is 81 for you? And if for your browser the limit is different: add your own answer to be upvoted?


For me, on a Mac the preview and final result are exactly the same:

         1         2         3         4         5         6         7         8
123456789012345678901234567890123456789012345678901234567890123456789012345678901

For 82 characters or more, I get a horizontal scrollbar. I've not noticed differences for different browsers.

         1         2         3         4         5         6         7         8
1234567890123456789012345678901234567890123456789012345678901234567890123456789012
7
  • With my current browser settings, I see 72 characters of your test block before I have to move the scroll bar. I would like to know if about 81 char is typical.
    – Mr.Wizard
    Commented Mar 8, 2011 at 15:55
  • 1
    @Mr.Wizard, that is at no zoom level? (Most browsers allow for pressing Ctrl-0 or Command-0 to get the default level.)
    – Arjan
    Commented Mar 8, 2011 at 15:58
  • And, @Mr.Wizard, you do not ALWAYS see the scrollbar, do you?
    – Arjan
    Commented Mar 8, 2011 at 16:01
  • I use non-standard font and zoom settings. That is why I want to know how things look for other people. And no, I do not see a bar on all code blocks, only on 73 characters or greater, it appears. BTW, I modified the test above, because there were trailing spaces.
    – Mr.Wizard
    Commented Mar 8, 2011 at 16:10
  • (@Mr.Wizard, your edit to remove trailing whitespace was a good one, but meanwhile I had deleted the other formats altogether, to be posted as standalone answers.)
    – Arjan
    Commented Mar 8, 2011 at 16:11
  • 7
    I also see 81 chars.
    – jjnguy
    Commented Mar 8, 2011 at 16:14
  • I see 81.9, does it count as 81 or 82...? :)
    – user173320
    Commented Jun 17, 2012 at 18:45
2

In the stock Android browser on a Nexus S (480 × 800, running Android 4.1), and the much smaller HTC Wildfire S (320 × 480, running 2.3.5), code wraps after 32 characters in portrait mode. But in landscape, the Nexus wraps after 59, and the Wildfire after 52.

In Chrome, the Nexus wraps at 31 and 57.

Like with the iPod, space characters on the Wildfire S seem to use more width than digits...

         1         2         3   
123456789012345678901234567890123

         1         2         3         4         5         6
1234567890123456789012345678901234567890123456789012345678901

Wildfire S:

Wildfire S Wildfire S

Stock browser on a Nexus S:

Nexus S Nexus S

Chrome on a Nexus S:

Chrome in Nexus S Chrome in Nexus S

3
  • Arjan I added the "ruler" to your post. Can you confirm it is correct?
    – Mr.Wizard
    Commented Jun 17, 2012 at 15:55
  • Yes, correct. A bit confusing in edit mode, as that does not use a fixed width font. Hence I copied it from another post, then seeing the numbers already there before pasting ;-)
    – Arjan
    Commented Jun 17, 2012 at 16:04
  • Wow, @Mr.Wizard, you even asked me if it was correct but: no, that rules was missing a digit! :-)
    – Arjan
    Commented Jul 24, 2012 at 14:47
1

I've noticed that I get significantly more characters per line if I work zoomed in one level. 91, in fact (Firefox 3.6). And the letters are bigger! Of course, this decreases the number of lines per screen, but that's an acceptable tradeoff in my opinion.

I get 81 at the default zoom level on FF, Chrome, Opera, and IE 8.

I get 91 at one zoom level in on FF, 86 with Chrome, 90 with Opera (though the spacing is broken for the tens line - weird), and 85 with IE. Firefox peaks at 91 for readable (not too small) zoom levels, but other browsers have peaks at zoom levels higher than 1.

         1         2         3         4         5         6         7         8         9
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
1
  • Very interesting. 60 % (unreadable) jumps from 91 up to 96, in Opera. And 140 % does same from 85 (=130 %) up to 91 while 150 % goes down to 82, while 20% offers sth like 120 characater. Commented Jul 24, 2012 at 15:00
1

Community wiki; please only upvote when the limit is 93 for you. And if for your browser the limit is different: add your own answer to be upvoted?


IE 8 (64bit), Zoom 100%, Textsize middle, maximum of 93 characters without scroll bar (preview and post):

         1         2         3         4         5         6         7         8         9
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123

For 94 characters or more, I get a horizontal scrollbar

         1         2         3         4         5         6         7         8
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234
1
  • " if for your browser the limit is different: add your own answer to be upvoted?" -> should I add a different answer if I use a different browser but the limit is 93 as well? Commented Mar 14, 2017 at 21:37
0

Code does not wrap if it is formatted as code in the question. I would not suggest wrapping any code ahead of time in your questions.

4
  • 1
    Pardon, I don't know why I said wrap, when I certainly was thinking of the horizontal scroll bar. It seems to me that it is better not to cause people to have to scroll, if I am making an arbitrary choice of line length.
    – Mr.Wizard
    Commented Mar 8, 2011 at 15:57
  • @Mr.Wizard, I understand better now. The limit is 81, but my advice still stands. IMO, I would not want to see a line broken just because it is more than 81 characters, if it is more readable at 85 characters then I would save leave it.
    – jzd
    Commented Mar 8, 2011 at 16:05
  • Thank you for the data point (81), and the advice.
    – Mr.Wizard
    Commented Mar 8, 2011 at 16:11
  • Code does wrap in the mobile theme.
    – Arjan
    Commented Jun 17, 2012 at 16:38
0

Community wiki; please only upvote when the limit is 72 for you? And if for your browser the limit is different: add your own answer to be upvoted?


         1         2         3         4         5         6         7
123456789012345678901234567890123456789012345678901234567890123456789012
0

iPad 2 it scrolls after 77 (in both landscape & portrait orientation)

         1         2         3         4         5         6         7
12345678901234567890123456789012345678901234567890123456789012345678901234567
0

My result is 86

         1         2         3         4         5         6         7         8
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456
1
  • I get 83 here, but 81 above on @KevinVermeer's answer. :|
    – Ry-
    Commented Jun 17, 2012 at 16:10
0

On an iPod with iOS 4.3.3, it wraps after 32 characters in portrait, and 52 in landscape.

         1         2         3   
123456789012345678901234567890123

         1         2         3         4         5
12345678901234567890123456789012345678901234567890123

Actually, it renders a bit odd, as spaces seem to need slightly more space than numbers?

You must log in to answer this question.

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