1

I know that Jupyter is using it's own CSS style which limits what you can do with HTML unless you edit it.

I try to display some info with more sophisticated way than Python print and for that I use:

from IPython.core.display import display, HTML display(HTML('<center>some header text</center>'))) 

Everything is left aligned though - both text and tables. Is there any simple workaround for this?

Or is there any other way to have centered tables in Jupyter Notebook?

1 Answer 1

2

You'll probably have to use a small bit of custom CSS in your html elements. The important bit is style='margin: 0 auto' For example:

from IPython.core.display import display, HTML display(HTML(""" <table style='margin: 0 auto'> <tr><th>Hi!</th><th>There!</th></tr> <tr><td>1</td><td>2</td></tr> </table> """)) 
Sign up to request clarification or add additional context in comments.

1 Comment

Hey! Thanks! That's correct. I've just found out moment ago. Also I recommend this blogpost for anyone who has similar problems: blog.booleanbiotech.com/ipython_notebook_tips.html

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.