# How to increase Code block font?!

**URL:** <https://forum.obsidian.md/t/how-to-increase-code-block-font/70013>\
**Category:** Devs: Theme Design & Custom CSS\
**Tags:** custom-css\
**Created:** [October 24, 2023, 2:36pm UTC](https://forum.obsidian.md/t/how-to-increase-code-block-font/70013 "2023-10-24T14:36:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zambala](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/z/858c86/32.png) [@zambala](https://forum.obsidian.md/u/zambala)\
**Post date:** [October 24, 2023, 2:36pm UTC](https://forum.obsidian.md/t/how-to-increase-code-block-font/70013/1 "2023-10-24T14:36:31Z")

</div>

How to increase the font size for Code block?!

The font-size for Code block is critically too small, especially on a dark background…

I have found this - but it works only in Reading View…

```auto
.markdown-preview-view code {
  font-family: Courier New !important;
  font-size: 18px !important;
}

```

How to do the same for Preview / Source Views ?!

---

<div class="post-metadata">

**Author:** ![ariehen](https://forum.obsidian.md/user_avatar/forum.obsidian.md/ariehen/32/46932_2.png) [@ariehen](https://forum.obsidian.md/u/ariehen)\
**Post date:** [October 24, 2023, 8:09pm UTC](https://forum.obsidian.md/t/how-to-increase-code-block-font/70013/2 "2023-10-24T20:09:47Z")

</div>

There is a custom variable / property you could use for size, but this will affect inline code as well as code blocks:

```css
body {
     --code-size: var(--font-smaller);
}

```

These are the variables defined in the default theme (you can of course just use your own `em` or `px` value in the above snippet and skip these).

```auto
  /* Relative font sizes */
  --font-smallest: 0.8em;
  --font-smaller: 0.875em;
  --font-small: 0.933em;

```

e.g.

```auto
body {
    --code-size: 1em;
}

```

* * *

If you only wanted to target code blocks, you could could use this (for Source mode and Live Preview) in addition to your CSS above (for Reading view).

```css
.cm-s-obsidian .HyperMD-codeblock {
  font-family: 'Courier New';
  font-size: 18px;
}

```

For inline code, it would be

```css
.cm-s-obsidian span.cm-inline-code {
  font-family: 'Courier New';
  font-size: 18px;
}

```

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [January 22, 2024, 8:10pm UTC](https://forum.obsidian.md/t/how-to-increase-code-block-font/70013/3 "2024-01-22T20:10:49Z")

</div>

Closed on January 22, 2024, 8:10pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
