How to Increase the Cell Width of Jupyter/IPython Notebook in Your Browser

Jupyter/IPython notebooks are a popular tool among data scientists for developing, documenting, and sharing their work. One common issue that arises when working with these notebooks is the default cell width, which can often be too narrow, making it difficult to read or write long lines of code.

Jupyter/IPython notebooks are a popular tool among data scientists for developing, documenting, and sharing their work. One common issue that arises when working with these notebooks is the default cell width, which can often be too narrow, making it difficult to read or write long lines of code.

In this blog post, I’ll walk you through several methods to increase the cell width of Jupyter/IPython notebooks in your browser. This will help you to improve readability and make the most out of your screen real estate.

Table of Contents

Method 1: Create a Custom CSS File

Another way to increase cell width in Jupyter notebooks is by creating a custom CSS file. This method allows you to set the cell width for all notebooks globally. To do this, follow these steps:

Initial Jupyter cell width

Jupyter Normal Width

  1. Locate the Jupyter configuration directory on your system. You can do this by running the following command in your terminal or command prompt:
jupyter --config-dir
  1. In the configuration directory, create a subdirectory called custom if it doesn’t already exist.
  2. Inside the custom directory, create a new file named custom.css.
  3. Open custom.css in your favorite text editor, and add the following CSS code:
.container {
    width: 100% !important;
}

.cell {
    width: 100%;
}

.code_cell {
    width: 100%;
}
  1. Save the file and restart your Jupyter notebook server.

Jupyter Full Width

Now, all your Jupyter notebooks will have their cell width set to 100% of the available screen width.

Method 2: Use Browser Developer Tools

A quick and temporary way to increase cell width in a Jupyter notebook is by using your browser’s developer tools. This method is useful if you just need to make a quick change and don’t want to modify any files. Here’s how to do it:

  1. Open your Jupyter notebook in your browser.
  2. Right-click on the cell you want to modify and select Inspect or Inspect Element, depending on your browser.

Jupyter Inspect

  1. In the developer tools window, locate the .cell or .code_cell CSS class.
  2. Modify the width property to your desired value, such as 100%.

Jupyter Inspect Width

This method only applies the changes to the current notebook session, and the changes will be lost when you refresh the page or close the browser.

Conclusion

In this blog post, we’ve covered two methods to increase the cell width of Jupyter/IPython notebooks in your browser. Give one or more of these methods a try to improve readability and make the most out of your screen real estate. Happy coding!


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Request a demo today to learn more.