---
title: "Background"
language: "en"
type: "Symbol"
summary: "Background is an option that specifies what background color to use."
keywords: 
- background color
- table background
- graphics background
- cell background
- colordef
- whitebg
canonical_url: "https://reference.wolfram.com/language/ref/Background.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Notebook Formatting & Styling"
    link: "https://reference.wolfram.com/language/guide/NotebookFormattingAndStyling.en.md"
  - 
    title: "Grids & Tables"
    link: "https://reference.wolfram.com/language/guide/GridsAndTables.en.md"
  - 
    title: "Cell Styling Options"
    link: "https://reference.wolfram.com/language/guide/CellStylingOptions.en.md"
  - 
    title: "Font Options"
    link: "https://reference.wolfram.com/language/guide/FontOptions.en.md"
  - 
    title: "Controls Options"
    link: "https://reference.wolfram.com/language/guide/ControlsOptions.en.md"
  - 
    title: "Graphics Annotation & Appearance"
    link: "https://reference.wolfram.com/language/guide/GraphicsAnnotationAndAppearance.en.md"
  - 
    title: "Colors"
    link: "https://reference.wolfram.com/language/guide/Colors.en.md"
  - 
    title: "Layout & Tables"
    link: "https://reference.wolfram.com/language/guide/LayoutAndTables.en.md"
  - 
    title: "Window Properties"
    link: "https://reference.wolfram.com/language/guide/WindowProperties.en.md"
  - 
    title: "Automated Reports"
    link: "https://reference.wolfram.com/language/guide/AutomatedReports.en.md"
  - 
    title: "Programmatic Notebook & Interface Customization"
    link: "https://reference.wolfram.com/language/guide/ProgrammaticNotebookAndInterfaceCustomization.en.md"
related_workflows: 
  - 
    title: "Change the Background Color of a Cell"
    link: "https://reference.wolfram.com/language/workflow/ChangeTheBackgroundColorOfACell.en.md"
  - 
    title: "Add Styling to Text"
    link: "https://reference.wolfram.com/language/workflow/AddStylingToText.en.md"
related_functions: 
  - 
    title: "Prolog"
    link: "https://reference.wolfram.com/language/ref/Prolog.en.md"
  - 
    title: "PlotRegion"
    link: "https://reference.wolfram.com/language/ref/PlotRegion.en.md"
  - 
    title: "ImageMargins"
    link: "https://reference.wolfram.com/language/ref/ImageMargins.en.md"
  - 
    title: "Item"
    link: "https://reference.wolfram.com/language/ref/Item.en.md"
  - 
    title: "Panel"
    link: "https://reference.wolfram.com/language/ref/Panel.en.md"
  - 
    title: "Framed"
    link: "https://reference.wolfram.com/language/ref/Framed.en.md"
  - 
    title: "CellFrame"
    link: "https://reference.wolfram.com/language/ref/CellFrame.en.md"
  - 
    title: "Style"
    link: "https://reference.wolfram.com/language/ref/Style.en.md"
  - 
    title: "WindowOpacity"
    link: "https://reference.wolfram.com/language/ref/WindowOpacity.en.md"
  - 
    title: "LightDarkSwitched"
    link: "https://reference.wolfram.com/language/ref/LightDarkSwitched.en.md"
  - 
    title: "ThemeColor"
    link: "https://reference.wolfram.com/language/ref/ThemeColor.en.md"
related_tutorials: 
  - 
    title: "Styles and Fonts in Output"
    link: "https://reference.wolfram.com/language/tutorial/TextualInputAndOutput.en.md#26291"
  - 
    title: "Graphics Directives and Options"
    link: "https://reference.wolfram.com/language/tutorial/TheStructureOfGraphicsAndSound.en.md#25633"
  - 
    title: "Options for Cells"
    link: "https://reference.wolfram.com/language/tutorial/ManipulatingNotebooks.en.md#3548"
  - 
    title: "Options for Notebooks"
    link: "https://reference.wolfram.com/language/tutorial/ManipulatingNotebooks.en.md#6483"
  - 
    title: "Tables and Matrices"
    link: "https://reference.wolfram.com/language/tutorial/TextualInputAndOutput.en.md#28366"
  - 
    title: "Grids, Rows, and Columns"
    link: "https://reference.wolfram.com/language/tutorial/GridsRowsAndColumnsOverview.en.md"
  - 
    title: "Formatted Output"
    link: "https://reference.wolfram.com/language/tutorial/TextualInputAndOutput.en.md#6589676"
---
# Background

Background is an option that specifies what background color to use.

## Details

* The setting for ``Background`` can be any color or opacity specification.

* ``Background`` is an option to such functions as ``Graphics``, ``Plot``, ``Text``, ``Panel``, ``Button``, and ``Cell``.

* When an object has option ``Background -> color``, the specified color will normally be used as a background throughout the region defined by the object.

* ``Style[expr, Background -> color]`` specifies that ``color`` should be used as the background only for the region defined by the bounding box of ``expr``.

* In constructs such as ``Grid``, ``Item`` can be used to specify that a background should fill the complete region for a particular item.

* In a top-level cell, the background is used only for the region inside the cell frame. If the cell's background color does not match its surroundings, the cell will include cell frame margins even if no cell frame is drawn. Cells displayed as inline, attached, etc. are not similarly affected.  »

* ``Background -> None`` specifies that no background should be used, so that in effect the background is transparent.

* ``Background -> Automatic`` specifies a background that follows the system appearance for the particular object or window used. For ``Inset``, ``Background -> Automatic`` specifies that the background should be taken from the graphic in which it appears.

* For objects such as ``Grid``, ``Column``, and ``Row``, the setting for ``Background`` can be a list that specifies backgrounds for individual columns, rows, or elements.

* In ``Dataset``, the setting for ``Background`` can be a pure function ``f`` that returns a color. The setting is given by ``f[item, position, data]``, where ``data`` is the dataset's first argument.

---

## Examples (18)

### Basic Examples (2)

Insert a background color behind any expression:

```wl
In[1]:= Style[{a, b, c}, Background -> Orange]

Out[1]= {a, b, c}
```

---

A background for graphics:

```wl
In[1]:= Graphics[{Circle[]}, Background -> Brown]

Out[1]= [image]

In[2]:= Graphics3D[{Opacity[.5], Sphere[]}, Background -> Pink]

Out[2]= [image]
```

### Scope (4)

Draw a grid with a pink background:

```wl
In[1]:= Grid[Table[x, {4}, {7}], Background -> Pink]

Out[1]=
|   |   |   |   |   |   |   |
| - | - | - | - | - | - | - |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
```

---

Any valid color directive can be used:

```wl
In[1]:= Table[ExpressionCell["abc", Background -> col], {col, {RGBColor[1, 1, 0], Hue[.5, .3, .1], GrayLevel[.5], LABColor[1, .4, .8], XYZColor[.6, .9, .2]}}]

Out[1]= {ExpressionCell["abc", Background -> RGBColor[1, 1, 0]], ExpressionCell["abc", Background -> Hue[0.5, 0.3, 0.1]], ExpressionCell["abc", Background -> GrayLevel[0.5]], ExpressionCell["abc", Background -> LABColor[1, 0.4, 0.8]], ExpressionCell["abc", Background -> XYZColor[0.6, 0.9, 0.2]]}
```

---

``LightDarkSwitched`` can be used to specify different colors in light and dark mode:

```wl
In[1]:= Graphics[Disk[], Background -> LightDarkSwitched[LightGreen, Purple]]

Out[1]= [image]
```

---

Draw the first item with a brown background:

```wl
In[1]:= Grid[{{Item[a, Background -> Brown], b}, {c, d}}]

Out[1]=
|   |   |
| - | - |
| a | b |
| c | d |
```

### Generalizations & Extensions (5)

Orange and magenta backgrounds for the first and second horizontal positions:

```wl
In[1]:= Grid[Table[x, {4}, {7}], Background -> {{Orange, Magenta}, None}]

Out[1]=
|   |   |   |   |   |   |   |
| - | - | - | - | - | - | - |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
```

Orange and magenta backgrounds for the first and last horizontal positions:

```wl
In[2]:= Grid[Table[x, {4}, {7}], Background -> {{Orange, {}, Magenta}, None}]

Out[2]=
|   |   |   |   |   |   |   |
| - | - | - | - | - | - | - |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
```

---

Orange and magenta backgrounds for the first and second vertical positions:

```wl
In[1]:= Grid[Table[x, {4}, {7}], Background -> {None, {Orange, Magenta}}]

Out[1]=
|   |   |   |   |   |   |   |
| - | - | - | - | - | - | - |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
```

---

Alternating brown and gray backgrounds:

```wl
In[1]:= Grid[Table[x, {4}, {7}], Background -> {{{Brown, Gray}}, None}]

Out[1]=
|   |   |   |   |   |   |   |
| - | - | - | - | - | - | - |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
```

Alternating background with pink superimposed in the first and last positions:

```wl
In[2]:= Grid[Table[x, {4}, {7}], Background -> {{{{Brown, Gray}}, {1 -> Pink, -1 -> Pink}}, None}]

Out[2]=
|   |   |   |   |   |   |   |
| - | - | - | - | - | - | - |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
```

---

Set the background for a subregion of the grid:

```wl
In[1]:= Grid[Table[x, {4}, {7}], Background -> {None, None, {{{1, 3}, {2, 4}} -> Pink}}]

Out[1]=
|   |   |   |   |   |   |   |
| - | - | - | - | - | - | - |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
| x | x | x | x | x | x | x |
```

---

Color background by value in ``Dataset`` :

```wl
In[1]:= Dataset[Take[...], Background -> {"age" -> (If[# > 9, Pink, Automatic]&)}]

Out[1]=
Dataset[{Association["class" -> "1st", "age" -> 29, "sex" -> "female", "survived" -> True], 
  Association["class" -> "1st", "age" -> 1, "sex" -> "male", "survived" -> True], 
  Association["class" -> "1st", "age" -> 2, "sex" -> "female", "survived ... ation["class" -> "1st", "age" -> 30, "sex" -> "male", "survived" -> False], 
  Association["class" -> "1st", "age" -> 25, "sex" -> "female", "survived" -> False], 
  Association["class" -> "1st", "age" -> 48, "sex" -> "male", "survived" -> True]}]
```

### Applications (3)

Show a table with alternating row background colors:

```wl
In[1]:= Grid[Table[Binomial[n, k], {n, 15}, {k, 15}], Background -> {None, {{Brown, Gray}}}]

Out[1]=
|    |     |     |      |      |      |      |      |      |      |      |     |     |    |   |
| -- | --- | --- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | --- | --- | -- | - |
| 1  | 0   | 0   | 0    | 0    | 0    | 0    | 0    | 0  ... 1716 | 1287 | 715  | 286  | 78   | 13  | 1   | 0  | 0 |
| 14 | 91  | 364 | 1001 | 2002 | 3003 | 3432 | 3003 | 2002 | 1001 | 364  | 91  | 14  | 1  | 0 |
| 15 | 105 | 455 | 1365 | 3003 | 5005 | 6435 | 6435 | 5005 | 3003 | 1365 | 455 | 105 | 15 | 1 |
```

---

Highlight the maximum in each column of a ``Dataset`` :

```wl
In[1]:= Dataset[Table[RandomReal[], {5}, {3}], Background -> (If[# === Max[#3[[All, #2[[2]]]]], Orange, Automatic]&)]

Out[1]=
Dataset[{{0.944403139405255, 0.8512639694829598, 0.25458252613728516}, 
  {0.0943867844434636, 0.7947130963695621, 0.7543065427663813}, 
  {0.755119099327137, 0.7551634775613756, 0.4279747578829458}, 
  {0.7933643767930671, 0.11703427673877309, 0.11067715519048194}, 
  {0.31289135597745843, 0.8980845865195362, 0.2786409304192128}}]
```

---

Display a grid of values as a heat map:

```wl
In[1]:= Dataset[Table[x y / 25., {x, 5}, {y, 5}], Background -> (LightDarkSwitched[Hue[1, #]]&)]

Out[1]=
Dataset[{{0.04, 0.08, 0.12, 0.16, 0.2}, {0.08, 0.16, 0.24, 0.32, 0.4}, 
  {0.12, 0.24, 0.36, 0.48, 0.6000000000000001}, {0.16, 0.32, 0.48, 0.64, 0.8}, 
  {0.2, 0.4, 0.6, 0.8, 1.}}]
```

### Properties & Relations (2)

Background color can be seen through a transparent object:

```wl
In[1]:=
{Graphics[{Opacity[0.5], Red, Disk[]}], 
	Graphics[{Opacity[0.5], Red, Disk[]}, Background -> Yellow]}

Out[1]= {[image], [image]}
```

---

A cell with a contrasting background color and no cell frame draws using ``CellFrameMargins`` :

```wl
In[1]:= CellPrint[ExpressionCell["abc", "Print", CellFrameMargins -> 20, Background -> Gray]]

"abc"
```

A background color matching the environment only uses ``CellFrameMargins`` if a cell frame is present:

```wl
In[2]:= CellPrint[ExpressionCell["abc", "Print", CellFrameMargins -> 20, Background -> ThemeColor["Background"]]]

"abc"

In[3]:= CellPrint[ExpressionCell["abc", "Print", CellFrameMargins -> 20, Background -> ThemeColor["Background"], CellFrame -> True]]

"abc"
```

``Background -> None`` is treated as a matching background color:

```wl
In[4]:= CellPrint[ExpressionCell["abc", "Print", CellFrameMargins -> 20, Background -> None]]

"abc"
```

``CellFrameMargins`` is not used for cells that are displayed as inline, attached, floating, etc.:

```wl
In[5]:= Row[{1, ExpressionCell[2, Background -> Gray], 3}]

Out[5]= 1ExpressionCell[2, Background -> GrayLevel[0.5]]3
```

### Possible Issues (1)

Some background colors contrast with default font colors well in light mode, but poorly in dark mode:

```wl
In[1]:= ExpressionCell["light mode contrast", Background -> Yellow]

Out[1]= ExpressionCell["light mode contrast", Background -> RGBColor[1, 1, 0]]
```

These can be fixed by wrapping the color in ``LightDarkSwitched`` :

```wl
In[2]:= ExpressionCell["light mode contrast", Background -> LightDarkSwitched[Yellow]]

Out[2]= ExpressionCell["light mode contrast", Background -> LightDarkSwitched[RGBColor[1, 1, 0]]]
```

Other colors contrast well in dark mode, but poorly in light mode:

```wl
In[3]:= ExpressionCell["light mode contrast", Background -> Purple]

Out[3]= ExpressionCell["light mode contrast", Background -> RGBColor[0.5, 0, 0.5]]
```

These can be fixed by using ``LightDarkSwitched`` with ``Automatic`` as the first argument:

```wl
In[4]:= ExpressionCell["light mode contrast", Background -> LightDarkSwitched[Automatic, Purple]]

Out[4]=
ExpressionCell["light mode contrast", Background -> LightDarkSwitched[Automatic, 
   RGBColor[0.5, 0, 0.5]]]
```

### Neat Examples (1)

Show 3D objects against a black background:

```wl
In[1]:= ContourPlot3D[$$x{}^{\wedge}4+y{}^{\wedge}4+z{}^{\wedge}4-(x{}^{\wedge}2+y{}^{\wedge}2+z{}^{\wedge}2)==-1/2$$, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> 15, MeshFunctions -> {#1^2 + #2^2 + #3^2&}, MeshShading -> {None, Directive[Blue, Specularity[White, 50]], None, Directive[Yellow, Specularity[White, 50]]}, PlotPoints -> 35, MeshStyle -> Opacity[.3], Axes -> False, Boxed -> False, Background -> Black]

Out[1]= [image]
```

## See Also

* [`Prolog`](https://reference.wolfram.com/language/ref/Prolog.en.md)
* [`PlotRegion`](https://reference.wolfram.com/language/ref/PlotRegion.en.md)
* [`ImageMargins`](https://reference.wolfram.com/language/ref/ImageMargins.en.md)
* [`Item`](https://reference.wolfram.com/language/ref/Item.en.md)
* [`Panel`](https://reference.wolfram.com/language/ref/Panel.en.md)
* [`Framed`](https://reference.wolfram.com/language/ref/Framed.en.md)
* [`CellFrame`](https://reference.wolfram.com/language/ref/CellFrame.en.md)
* [`Style`](https://reference.wolfram.com/language/ref/Style.en.md)
* [`WindowOpacity`](https://reference.wolfram.com/language/ref/WindowOpacity.en.md)
* [`LightDarkSwitched`](https://reference.wolfram.com/language/ref/LightDarkSwitched.en.md)
* [`ThemeColor`](https://reference.wolfram.com/language/ref/ThemeColor.en.md)

## Tech Notes

* [Styles and Fonts in Output](https://reference.wolfram.com/language/tutorial/TextualInputAndOutput.en.md#26291)
* [Graphics Directives and Options](https://reference.wolfram.com/language/tutorial/TheStructureOfGraphicsAndSound.en.md#25633)
* [Options for Cells](https://reference.wolfram.com/language/tutorial/ManipulatingNotebooks.en.md#3548)
* [Options for Notebooks](https://reference.wolfram.com/language/tutorial/ManipulatingNotebooks.en.md#6483)
* [Tables and Matrices](https://reference.wolfram.com/language/tutorial/TextualInputAndOutput.en.md#28366)
* [Grids, Rows, and Columns](https://reference.wolfram.com/language/tutorial/GridsRowsAndColumnsOverview.en.md)
* [Formatted Output](https://reference.wolfram.com/language/tutorial/TextualInputAndOutput.en.md#6589676)

## Related Guides

* [Notebook Formatting & Styling](https://reference.wolfram.com/language/guide/NotebookFormattingAndStyling.en.md)
* [Grids & Tables](https://reference.wolfram.com/language/guide/GridsAndTables.en.md)
* [Cell Styling Options](https://reference.wolfram.com/language/guide/CellStylingOptions.en.md)
* [Font Options](https://reference.wolfram.com/language/guide/FontOptions.en.md)
* [Controls Options](https://reference.wolfram.com/language/guide/ControlsOptions.en.md)
* [Graphics Annotation & Appearance](https://reference.wolfram.com/language/guide/GraphicsAnnotationAndAppearance.en.md)
* [`Colors`](https://reference.wolfram.com/language/guide/Colors.en.md)
* [Layout & Tables](https://reference.wolfram.com/language/guide/LayoutAndTables.en.md)
* [Window Properties](https://reference.wolfram.com/language/guide/WindowProperties.en.md)
* [Automated Reports](https://reference.wolfram.com/language/guide/AutomatedReports.en.md)
* [Programmatic Notebook & Interface Customization](https://reference.wolfram.com/language/guide/ProgrammaticNotebookAndInterfaceCustomization.en.md)

## Related Workflows

* [Change the Background Color of a Cell](https://reference.wolfram.com/language/workflow/ChangeTheBackgroundColorOfACell.en.md)
* [Add Styling to Text](https://reference.wolfram.com/language/workflow/AddStylingToText.en.md)

## Related Links

* [An Elementary Introduction to the Wolfram Language: Options](https://www.wolfram.com/language/elementary-introduction/20-options.html)

## History

* Introduced in 1991 (2.0) \| Updated in 1996 (3.0) ▪ [2007 (6.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn60.en.md) ▪ [2012 (9.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn90.en.md) ▪ [2020 (12.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn121.en.md)