jupyter-notebookmarkdown

jupyter notebook markdown code cell background color


If I write code block in a text cell with code quote as below

```java
//some code here
```

Can I change the code block background color to light grey for all such code cells?

Update[10/12/19]

per @vi_rises's comments, if using jupyter, then config file path is:

.jupyter/custom/custom.css

Add below content will change text line background color:

.rendered_html code.language-java {
    background-color: #e5e5e5;
}

markdown cell text: java code section start

```java
/* HelloWorld.java
 */

public class HelloWorld
{
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
```

java code section end

The output looks like below: enter image description here

I wish to whole java code rectangle area if it's possible!


Solution

  • Add the below css property to the custom.css file present under ~/.ipython/profile_default/static/custom/custom.css

    code.language-java {
    background-color: #e5e5e5;
    }
    

    You can change color as per your need.

    before executing

    after executing