5

There is a small problem that might annoy me from time to time (idk if there are other people feel the same). Every time I use view page source from any browser, the text always turn out to be ugly and small (my computer's resolution is 1920x1080 with 17 inches in particular, which makes the letter extremely small and hard to see). Is there a way to change the font and the size in the view page source section from any browser? (Chrome, for example)

I know I could zoom in the page by mouse scrolling or by "ctrl" + "+", but that's not really the way I want to solve it.

Thanks

ryf9059
  • 729
  • 3
  • 14
  • 23
  • 1
    FWIW: in Chrome zooming with CTRL/CMD +/- does work but it also affects the page itself, so when you close the source and go back the whole site is smaller/bigger. This makes it extremely frustrating to use and not a good solution. – jerclarke Jun 19 '14 at 14:59

4 Answers4

25

As of Chrome 32.0.1700.76 the custom.css doesn't work as outlined below.

Please see an updated answer here: Custom.css has stopped working in 32.0.1700.76 m Google Chrome update

The old way is as follows:

Go to the following directory:

%LOCALAPPDATA%\Google\Chrome\User Data\Default\User StyleSheets\

Mac:

~/Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css

and open the Custom.css file. If it doesn't exist, create one.

Add the following lines:

body.platform-windows .monospace, 
body.platform-windows .source-code, 
td.webkit-line-content {
  font-size: 15px !important;
  font-family: Consolas, Lucida Console, monospace !important;
  tab-size: 2;
}

All you're doing is customizing classes used internally by Chrome. The .monospace class is pretty self evident. The .source-code class affects items in your developer tools (F12). The one that you are looking for is the td.webkit-line-content, it's the one that applies style to the line items when you choose to View page source.

You can also edit the line numbers as well by adding styles for td.webkit-line-number and can also edit the line number background by adjusting the style for div.webkit-line-gutter-backdrop.

Cheers.

Community
  • 1
  • 1
Jeff Johnson
  • 1,095
  • 10
  • 15
  • 1
    Thanks for this. Saved my bacon when I accidentally uninstalled whatever default font Chrome uses for the View Source dialog. This should be the correct answer, but hey what does the OP know?! – adaam Jun 13 '13 at 14:49
  • 1
    Support for overriding stylesheets has been removed as of Chrome 33. See: http://www.reddit.com/r/chrome/comments/1ymfgw/user_stylesheet_customcss_support_removed_in/ –  Sep 01 '14 at 22:53
2

As Jeff Johnson said - for Mac the Stylesheet is under:

~/Library/Application\ Support/Google/Chrome/Default/User\ StyleSheets/Custom.css
Matt
  • 74,352
  • 26
  • 153
  • 180
mansur
  • 248
  • 2
  • 9
2

On linux platform (Ubuntu) the Custom.css file is in folder:

~/.config/google-chrome/Profile #/User Stylesheets/Custom.css
sbrbot
  • 6,169
  • 6
  • 43
  • 74
1

You could assign your favorite editor to view the source from IE and FireFox.

View Webpage Source Code in Your Favorite Text Editor – Firefox

Use an Alternate Source Viewer with IE

Hameed
  • 2,227
  • 1
  • 21
  • 31