# Improved code block sizing & color scheme

**URL:** https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946
**Category:** UX
**Tags:** feedback, design-experiment
**Created:** [November 1, 2024, 3:10am UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946 "2024-11-01T03:10:30Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![fitzy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fitzy/32/192549_2.png) [@fitzy](https://meta.discourse.org/u/fitzy)
#### Post date: [November 1, 2024, 3:10am UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/1 "2024-11-01T03:10:30Z")

</div>

We’re experimenting with reducing the size of text and the line height, and increasing the height of code blocks, in order to improve readability of larger blocks of code. This is mostly problematic for large blocks of code exceeding 20 or more lines. The result is more code can be seen in the regular viewport.

**Before**

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/4/5/9455b910ee57f7922facd9e5eef8710568086425.png)

**After**

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/3/a/e3a98a06faeea9cc5658110b7da7259fd80a3359.png)

The change has been made here:

[https://github.com/discourse-org/design-experiments/pull/75](https://github.com/discourse-org/design-experiments/pull/75)

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [November 1, 2024, 3:36pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/2 "2024-11-01T15:36:38Z")

</div>

It seems like changing the font size of `inline code like this` is probably an unintentional side-effect?

---

<div class="post-metadata">

### Author: ![fitzy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fitzy/32/192549_2.png) [@fitzy](https://meta.discourse.org/u/fitzy)
#### Post date: [November 1, 2024, 7:44pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/3 "2024-11-01T19:44:49Z")

</div>

Yes that was unintentional, we should modify it so that only full blocks are changed and not inline code.

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [November 3, 2024, 6:12pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/4 "2024-11-03T18:12:13Z")

</div>

FWIW, I just use this on my hackity hack dev instance:

```scss
pre code {
  font-size: var(--font-down-1);
}

```

result

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/8/f/18f40e7b50986e0757077e52fe537acf19cace6d.png)

---

<div class="post-metadata">

### Author: ![fitzy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fitzy/32/192549_2.png) [@fitzy](https://meta.discourse.org/u/fitzy)
#### Post date: [November 3, 2024, 10:10pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/5 "2024-11-03T22:10:09Z")

</div>

I’ve sent a PR to remove styling changes to inline monospace text, and also increase the line height slightly in `<pre>` blocks.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 4, 2024, 12:59am UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/6 "2024-11-04T00:59:21Z")

</div>

This is sadly hurting readability on shorter snippets.

Eg:

 ![The image shows a screenshot of a coding question, with a prompt and code snippet at the top and a "Solution" button at the bottom. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/3/4/1/341cfa5ee90183e71983eee02e81c29d4884dda6.png)

Font is smaller, line height shorter.

Can this only impact very long code blocks? Should this even be a core change @jordan.vidrine ?

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [November 5, 2024, 7:08pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/8 "2024-11-05T19:08:16Z")

</div>

I want to also highlight the difference here between this experiment and stack overflow.

**Current experiment**

 ![image](https://global.discourse-cdn.com/meta/original/4X/a/b/7/ab75c71c0dc5984a7c08a474eb081d1a1b922628.png)

**Stack overflow**

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/e/7/5e73891357a501e251d0c92f58f770523b0379b3.png)

Some things I notice immediately is:

- their font is slightly larger
- we have bold on our function titles, they do not

I need to dig more into hljs and see why our use case is bolding titles.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 5, 2024, 8:36pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/9 "2024-11-05T20:36:19Z")

</div>

I love that you had a look at Stack Oveflow, cause if anyone figured out how to display code blocks it would be them.

Another observation, font size does not appear to be changing despite it changing… (15px → 13px but the colors compensate some)

Visual rhythm and line height all feel a lot better here:

**Stack Overflow**

 ![The image shows a snippet of Python code with text that reads, "The following is not the use case I actually need, but it serves as a perfectly fine example. When I try to run the following code I get the legend appears without the corresponding colors of the lines. I am running matplotlib version 3.8.3." (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/c/9/7/c975fe15028c567eccb5c36253b217fae6aa27bf.png)

**Current Experiment**

 ![The image shows an example of Python code that generates a legend with specific colors using matplotlib. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/0/c/7/0c78e6583aedc0b61dafdea1b5af1d0506b4d465.png)

Line height is noticeably a problem and our “shrinking” went too far cause our base font is larger and roomier than Stack Oveflow.

* * *

I very much support de-bolding in our current experiment and increasing size, line height.

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [November 5, 2024, 9:31pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/10 "2024-11-05T21:31:54Z")

</div>

This PR made the following changes: [https://github.com/discourse-org/design-experiments/pull/77](https://github.com/discourse-org/design-experiments/pull/77)

| Before | After |
| --- | --- |
| ![](https://global.discourse-cdn.com/meta/original/4X/b/2/a/b2ad97a57b60915904eb597e0262751f0c458e96.png) | ![](https://global.discourse-cdn.com/meta/original/4X/d/e/d/ded4b98af8be646fccac2e691b6aefa26c37b363.png) |
| ![](https://global.discourse-cdn.com/meta/original/4X/9/f/8/9f820489e731104b57af3b1b0cc584f4ae88c936.png) | ![](https://global.discourse-cdn.com/meta/original/4X/f/0/2/f023857f31b098e2c90fb5a72dc6a97d9f260400.png) |
| ![](https://global.discourse-cdn.com/meta/original/4X/d/a/0/da091a37c506242a2fe7dac22275049f1941d899.png) | ![](https://global.discourse-cdn.com/meta/original/4X/c/7/2/c723dc7f673fa883cd21882c9859f0a4fb9fab36.png) |

---

<div class="post-metadata">

### Author: ![bryce](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bryce/32/377822_2.png) [@bryce](https://meta.discourse.org/u/bryce)
#### Post date: [November 5, 2024, 9:52pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/11 "2024-11-05T21:52:00Z")

</div>

That looks great, Jordan. In this case, I think using the consistent font weight helps readability. I’m liking the increased padding too.

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [November 5, 2024, 9:57pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/12 "2024-11-05T21:57:55Z")

</div>

> [@bryce](#):
>
> I think using the consistent font weight helps readability.

Thanks, I agree. I think I’d like to also take a look at colors and why hljs is using the colors it is using. I havent seen this color pattern used anywhere online.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 5, 2024, 11:19pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/13 "2024-11-05T23:19:04Z")

</div>

I am a fan of the typography changes, but I feel the dark background is too much. The lighter background is a lot easier to read.

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [November 5, 2024, 11:29pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/14 "2024-11-05T23:29:41Z")

</div>

Change incoming.

[https://github.com/discourse-org/design-experiments/pull/78](https://github.com/discourse-org/design-experiments/pull/78)

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [November 6, 2024, 12:36am UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/15 "2024-11-06T00:36:03Z")

</div>

After more research, I see that the colors we are using are based on a dated scheme used by github possibly 10 years ago, or as early as 4.

Is there room here to change the default colors to something updated?

Github has an updated color scheme since then, along with other options to be a default light scheme.

**Stack overflow**

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/8/0/f80d0022b76ffb6a5099e56f06301325c206ca14.png)

**Atom One Light**

 ![image](https://global.discourse-cdn.com/meta/original/4X/a/b/2/ab2adbd74824166ef5f52e9050012f716db7053a.png)

**New Github**

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/f/b/1fb5637f7ebf76127d2e1fbf5a22299a5a0eb555.png)

**hljs default** 🤢

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/5/b/d5be8f5de1c55164c4db0eeb683946f2007d731e.png)

---

<div class="post-metadata">

### Author: ![fitzy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fitzy/32/192549_2.png) [@fitzy](https://meta.discourse.org/u/fitzy)
#### Post date: [November 6, 2024, 12:39am UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/16 "2024-11-06T00:39:04Z")

</div>

My personal preference would be toward something with more muted colours - in your examples, Stack Overflow is my choice.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [November 6, 2024, 10:22pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/17 "2024-11-06T22:22:26Z")

</div>

after a couple days I still have to squint a bit with the smaller font-size, I don’t think it’s worth the space savings

---

<div class="post-metadata">

### Author: ![fitzy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fitzy/32/192549_2.png) [@fitzy](https://meta.discourse.org/u/fitzy)
#### Post date: [November 6, 2024, 10:28pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/18 "2024-11-06T22:28:16Z")

</div>

Do you feel the same on Stack Overflow (for example)? The font size and line height calculations is the same now between Discourse and SO.

`max-height` on Discourse is slightly less at 500px vs 600px.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [November 6, 2024, 11:05pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/19 "2024-11-06T23:05:45Z")

</div>

The contrast is much worse in our case and it makes a big difference when you’re trying to read small text, for example (Stack Overflow on the right):

 ![The image shows a screenshot of a coding window with code visible in the editor. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/7/a/7/7a720fb99ea09c697fb522782332cfa29f643426.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/8/7/e87f2cb8c10dd8303c56d05ba079c000cfa91146.png)

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [November 6, 2024, 11:14pm UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/20 "2024-11-06T23:14:49Z")

</div>

> [@awesomerobot](#):
>
> The contrast is much worse in our case and it makes a big difference when you’re trying to read small text, for example (Stack Overflow on the right):

Yeah I see what you mean here.

How do you feel about these changes in the PR I have up: [https://github.com/discourse-org/design-experiments/pull/79](https://github.com/discourse-org/design-experiments/pull/79)

 ![image](https://global.discourse-cdn.com/meta/original/4X/6/b/0/6b057a2afb2c89e51919ec9bc6b82d9d6244915b.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/0/a/70af08952915ae85daa1a2f0e754b75644be9bec.png)

Here is an option where I add black to the bg in dark mode, instead of using something based on secondary or primary. I do this via `rgba(0,0,0,0.25)`

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/1/4/f14ad173ce983950464e1600e866fe102917763b.png)

---

<div class="post-metadata">

### Author: ![robbie.morrison](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@robbie.morrison](https://meta.discourse.org/u/robbie.morrison)
#### Post date: [November 7, 2024, 10:22am UTC](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946/21 "2024-11-07T10:22:06Z")

</div>

Could someone do a test with the recent code block line numbering component/theme feature also included?&nbsp;TIA.

[Next page](https://meta.discourse.org/t/improved-code-block-sizing-color-scheme/333946.md?page=2)
