Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color in markdown cells ipython/jupyter notebook?

People also ask

How do I change the color of text in Markdown?

Markdown doesn't support color but you can inline HTML inside Markdown, e.g.: <span style="color:blue">some *blue* text</span>. As the original/official syntax rules state (emphasis added): Markdown's syntax is intended for one purpose: to be used as a format for writing for the web.

How do I change the markdown cell in Jupyter notebook?

You can change the cell type of any cell in Jupyter Notebook using the Toolbar. The default cell type is Code. To use the Keyboard Shortcuts, hit the esc key. After that, you can change a cell to Markdown by hitting the m key, or you can change a cell to Code by hitting the y key.

How do you edit markdown in Jupyter lab?

To edit a markdown file in JupyterLab: Goto the File Browser [CTRL+SHIFT+F] and select the markdown file you want to edit.

How do you make a markdown cell bold in Jupyter notebook?

For example, to make a word bold, surround it with the HTML code for bold ( <b>text</b> instead of the Markdown code. You can attach image files directly to a notebook in Markdown cells by dragging and dropping it into the cell.


You can simply use raw html tags like

foo <font color='red'>bar</font> foo

Be aware that this will not survive a conversion of the notebook to latex.

As there are some complaints about the deprecation of the proposed solution. They are totally valid and Scott has already answered the question with a more recent, i.e. CSS based approach. Nevertheless, this answer shows some general approach to use html tags within IPython to style markdown cell content beyond the available pure markdown capabilities.


Similarly to Jakob's answer, you can use HTML tags. Just a note that the color attribute of font (<font color=...>) is deprecated in HTML5. The following syntax would be HTML5-compliant:

This <span style="color:red">word</span> is not black.

Same caution that Jakob made probably still applies:

Be aware that this will not survive a conversion of the notebook to latex.


An alternative way to do that, is to enter a LaTeX environment within the notebook and change color from there (which is great if you are more fluent in LaTeX than in HTML). Example:

$\color{red}{\text{ciao}}$

would display ciao in red.


For example, if you want to make the color of "text" green, just type:

<font color='green'>text</font>

The text color can be changed using,

<span style='color:green'> message/text </span>

If none of the above suggestions works for you, try using the style attribute.

**Notes**
<p style="color:red;">ERROR: Setting focus didn't work for me when I tried from jupyter. However it worked well when I ran it from the terminal</p>

This gives me the following result

enter image description here