Cells as Wolfram Language Expressions

Like other objects in the Wolfram Language, the cells in a notebook, and in fact the whole notebook itself, are all ultimately represented as Wolfram Language expressions. With the standard notebook front end, you can use the command Show Expression to see the text of the Wolfram Language expression that corresponds to any particular cell.

Show Expression menu itemtoggle between displayed form and underlying Wolfram Language expression
Ctrl+* or Ctrl+8 (between existing cells)put up a dialog box to allow input of a cell in Wolfram Language expression form

Handling Cell expressions in the notebook front end.

Here is a cell displayed in its usual way in the front end.


Here is the underlying Wolfram Language expression that corresponds to the cell.


Cell[contents,"style"]a cell with a specific style
Cell[contents,"style",options]a cell with additional options specified
Cell[contents,"style1","style2",,options]a cell with several styles

Wolfram Language expressions corresponding to cells in notebooks.

Within a given notebook, there is always a collection of styles that can be used to determine the appearance and behavior of cells. Typically the styles are named so as to reflect what role cells which have them will play in the notebook.

"Title"the title of the notebook
"Section"a section heading
"Subsection"a subsection heading
"Text"ordinary text
"Input"Wolfram Language input
"Output"Wolfram Language output

Some typical cell styles defined in notebooks.

Here are several cells in different styles.


Here are the expressions that correspond to these cells.


A particular style such as "Section" or "Text" defines various settings for the options associated with a cell. You can override these settings by explicitly setting options within a specific cell.

Here is the expression for a cell in which options are set to use a gray background and to put a frame around the cell.


This is how the cell looks in a notebook.


default value
CellFrameFalsewhether to draw a frame around the cell
BackgroundAutomaticwhat color to draw the background for the cell
EditableTruewhether to allow the contents of the cell to be edited
TextAlignmentLefthow to align text in the cell
FontSize12the point size of the font for text
CellTags{}tags to be associated with the cell

A few of the large number of possible options for cells.

The standard notebook front end for the Wolfram System provides several ways to change the options of a cell. In simple cases, such as changing the size or color of text, there will often be a specific menu item for the purpose. But in general you can use the Option Inspector that is built into the front end. This is typically accessed using the Option Inspector menu item in the Format menu.

Change settings for specific options with menus.
Look at and modify all options with the Option Inspector.
Edit the textual form of the expression corresponding to the cell.
Change the settings for all cells with a particular style.

Ways to manipulate cells in the front end.

Sometimes you will want just to change the options associated with a specific cell. But often you may want to change the options associated with all cells in your notebook that have a particular style. You can do this by using the Edit Stylesheet command in the front end to create a custom stylesheet associated with your notebook. Then use the controls in the stylesheet to create a cell corresponding to the style you want to change and modify the options for that cell.

CellPrint[Cell[]]insert a cell into your currently selected notebook
CellPrint[{Cell[],Cell[],}]insert a sequence of cells into your currently selected notebook

Inserting cells into a notebook.

This inserts a section cell into the current notebook:
Click for copyable input


This inserts a text cell with a frame around it:
Click for copyable input


CellPrint allows you to take a raw Cell expression and insert it into your current notebook. The cell created by CellPrint is grouped with the input and will be overwritten if the input is reevaluated.