Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the background color code block markdown github

I am using below syntax

```yaml
 stages:
   - build
   - test
   - deploy
```

This helps me to get proper text color and getting box but how to change the background color of the box.

like image 744
mayur rahatekar Avatar asked Jan 31 '26 08:01

mayur rahatekar


1 Answers

TL;DR: GitHub overrides any styling you apply to your document when it renders it using its own flavor.

However, for other places you can do this with HTML and CSS if you wrap it in a <div> ... </div> pair:

# Code

## Vanilla

``python
print("hello world!")
``

## Flavored V1

<div style="background-color: rgb(50, 50, 50);">

``python
print("Yo!")
``

</div>

I had to remove a backtick ` from each code section in my example in order to render it properly here.

The file above renders as below on VSCode:

enter image description here

You can further change the appearance with CSS, however, I wouldn't recommend it.

P.S: GitHub has global dark themes available under settings.

like image 152
M.H. Tajaddini Avatar answered Feb 02 '26 01:02

M.H. Tajaddini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!