Custom styling for IPython notebooks with 3 lines of code

A little-known trick with IPython notebooks is that its easy to create custom styles and typography. You only need 3 in lines of code:

Here’s a notebook using this style.

What does the last line do? It opens a css file saved on GitHub (, then applies the style rules to the notebook with the HTML() function.

Here are some curiosities we encountered in creating our own IPython notebook style sheet:

  • !important; was necessary to override many styles
  • css comments (/* … */) were not appreciated
  • css rules can affect the notebook top menus –  be careful changing <ul> and <li> rules

The top image in this post is from Lorena Barba’s amazing notebooks on fluid dynamics.