Search code examples
cssfont-sizeuserscripts

Changing font size of code in StackExchange


Can the blocks of code on StackExchange posts ({} icon the toolbar) be reduced or increased in size by changing the font size, or any other means?


Solution

  • Through a userscript, you can:

    // ==UserScript==
    // @name     Stack Exchange Code Formatting CSS
    // @include  http://*.stackexchange.com/*
    // @include  http://*.stackoverflow.com/*
    // @include  http://*.serverfault.com/*
    // @include  http://*.superuser.com/*
    // @grant    GM_addStyle
    // ==/UserScript==
    
    GM_addStyle ( "code,pre { font-size:14px !important; white-space:pre-wrap }");
    

    The default font size is 13px. Applying the font-size to code is what works. In my example, I wanted to word-wrap the (pre) text so I made it simpler by applying the two properties to both.