# Modify font size in code block only for certain shell logs

**URL:** <https://forum.obsidian.md/t/modify-font-size-in-code-block-only-for-certain-shell-logs/99779>\
**Category:** Devs: Theme Design & Custom CSS\
**Tags:** custom-css\
**Created:** [April 21, 2025, 12:45pm UTC](https://forum.obsidian.md/t/modify-font-size-in-code-block-only-for-certain-shell-logs/99779 "2025-04-21T12:45:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baelor](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/b/c67d28/32.png) [@Baelor](https://forum.obsidian.md/u/Baelor)\
**Post date:** [April 21, 2025, 12:45pm UTC](https://forum.obsidian.md/t/modify-font-size-in-code-block-only-for-certain-shell-logs/99779/1 "2025-04-21T12:45:13Z")

</div>

### What I’m trying to do

I want to only modify font size on codeblocks that are tagged as such, for example for lengthy logs.

 ![image](https://forum.obsidian.md/uploads/default/original/3X/5/2/52287de132a8f211e40e300900521f53b7de20f7.png)

For all other cases I’d like to keep the font size of code blocks as it is:

 ![image](https://forum.obsidian.md/uploads/default/original/3X/9/f/9f0f13c8515f300c4022c3d5aac3810d329e9955.png)

### Things I have tried

Using [this thread](https://forum.obsidian.md/t/how-to-increase-code-block-font/70013/2) I was able to modify the font size of all code blocks using custom css:

```auto
.markdown-preview-view code {
  font-size: 8px !important;
}
.cm-s-obsidian .HyperMD-codeblock {
  font-size: 8px;
}

```

However, I’m not yet sure how to target only specific code blocks or if it makes more sense to define a new “language” like `Shell-Logs` for this case?

EDIT:  
I did define a new language `shell-log` that is rendered smaller, but I only managed this in reading mode. In live-preview it does not work.

```auto
.markdown-reading-view pre code.language-shell-log {
  font-size: 8px; 
}

```

Reading mode:

 ![image](https://forum.obsidian.md/uploads/default/original/3X/a/0/a066bb23a5f8b76f3cdfc83c8194e49cc5393f44.png)

Live-preview mode:

 ![image](https://forum.obsidian.md/uploads/default/original/3X/f/4/f45628933f5d224716987eb3d5cd29fd4243dd70.png)

---

<div class="post-metadata">

**Author:** ![bladeacer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/bladeacer/32/79613_2.png) [@bladeacer](https://forum.obsidian.md/u/bladeacer)\
**Post date:** [June 26, 2025, 9:25am UTC](https://forum.obsidian.md/t/modify-font-size-in-code-block-only-for-certain-shell-logs/99779/2 "2025-06-26T09:25:24Z")

</div>

Reading mode and live preview works quite differently in terms selector.

---

<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:** [September 24, 2025, 9:25am UTC](https://forum.obsidian.md/t/modify-font-size-in-code-block-only-for-certain-shell-logs/99779/3 "2025-09-24T09:25:48Z")

</div>

Closed on September 24, 2025, 9:25am UTC

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