How do I increase the cell width of the Jupyter/ipython notebook in my browser?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
The classic Jupyter Notebook uses a centered container with a fixed maximum width, which can feel cramped on large displays. If your code cells, tables, or plots are wider than the default layout, the simplest fix is to inject a small amount of CSS or place the same CSS in the notebook’s custom stylesheet.
The Fastest Per-Notebook Fix
If you want one notebook to use more horizontal space, inject CSS from a cell with IPython.display.HTML.
Run that cell once after opening the notebook. The classic notebook page will expand the main container to roughly the full browser width.
This approach is convenient because it travels with the notebook and does not require editing configuration files.
Make the Change Persistent in Classic Notebook
If you want the wider layout every time you open the classic notebook interface, place the CSS in custom.css.
A common location is:
Then add the rule:
After saving the file, refresh the notebook page. This is the persistent version of the same idea.
Adjusting More Than the Main Container
Sometimes the outer container is not the real problem. Wide output areas, prompt columns, or specific rendered elements may still need adjustment.
For example, if code input feels narrow because prompt columns consume too much horizontal space, you may also tune related selectors.
Be conservative here. It is easy to pile on CSS until the notebook looks inconsistent across browsers.
Jupyter Notebook Versus JupyterLab
The old IPython notebook and the classic Jupyter Notebook expose the familiar .container rule, which is why the examples above are so common. JupyterLab uses a different DOM structure and generally does not respond to the same selector in the same way.
If you are using JupyterLab, first confirm that you are changing the right interface. Many “this CSS does nothing” reports are simply caused by applying a classic-notebook tweak to JupyterLab.
For Lab, layout customization usually goes through extensions, themes, or Lab-specific overrides rather than the classic custom.css path.
When a Wider Notebook Is Actually the Wrong Fix
Wider cells help with broad tables and long code lines, but they can also reduce readability for ordinary prose. Extremely wide markdown paragraphs are harder to scan, and wide code blocks can encourage poor line-length discipline.
Before changing the layout globally, ask whether the real problem is one specific output. For example, a large DataFrame may be better handled by narrowing selected columns, using pagination tools, or opening the table in a dedicated viewer.
The same is true for plots. Sometimes the right fix is increasing the figure size rather than stretching the whole notebook interface.
Common Pitfalls
Applying the .container rule in JupyterLab is a common failure because that selector targets the classic notebook layout.
Forgetting !important can leave the default rule in control, depending on the version and theme.
Editing custom.css and expecting a running page to update automatically is another common miss. Refresh the browser after saving changes.
Finally, do not assume wider is always better. Large displays can turn text-heavy notebooks into hard-to-read documents if you remove too much structure.
Summary
- the quickest way to widen classic notebook cells is a small injected CSS rule for
.container - use
IPython.display.HTMLfor a per-notebook change - use
~/.jupyter/custom/custom.cssfor a persistent classic-notebook change - classic Notebook and JupyterLab use different layouts, so the same selector may not work in both
- widen the notebook only when it improves the actual workflow, not by default for every case
Related reading
- how do I insert a column at a specific column index in pandas?
- How do I make a single legend for many subplots?
- How do I make a U-matrix?
- How do I plot a classification graph of a SVM in R
- How do I input multiple exogenous variables into a SARIMAX model in statsmodel?
- How do I install a pip package globally instead of locally?
- How do I plot in real-time in a while loop?
- How do I predict new data's cluster after clustering training data?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.