I'm applying a background color to code blocks in org-mode, as shown in this line from my colortheme:

'(org-block ((t (:background "#F5F5F5" :family "Source Code Pro" :height 140))))

expanded item with code block

When I collapse an item that contains a code block, the code block's background color extends from the end of the item's heading to the edge of the window, which I did not expect -- I expected collapsing the item would hide any evidence of the contained code-block.

collapsed item with code block

Is there any way to prevent the code block background from "bleeding through" like this?

2 Answers 2


I found that adding a blank line past the source block prevents the bleeding.

  • Confirmed. But is this a bug or by design? It seems header formatting should be independent of its collapse/expand state (except for the presence of ellipses to indicate collapsed content.)
    – Snelephant
    Commented Feb 2, 2018 at 21:19
  • Correction: This issue appears be unique to specific themes. For example, leuven theme does not exhibit the above behavior.
    – Snelephant
    Commented Feb 2, 2018 at 21:45
  • Has this issue been resolved? I am still observing it on my system
    – GenaU
    Commented Jul 19, 2021 at 2:20

You found a known bug tracked here:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.