The display CSS property defines the display type of an element, which consists of the two basic qualities of how an element generates boxes — the outer display type defining how the box participates in flow layout , and the inner display type defining how the children of the box are laid out.

Some values of display are fully defined in their own individual specifications; see the table at the end of this document for links to all relevant specifications. The full list of values is as below.

/* <display-outside> values */
display: block;
display: inline;
display: run-in;

/* <display-inside> values */
display: flow;
display: flow-root;
display: table;
display: flex;
display: grid;
display: ruby;

/* <display-outside> plus <display-inside> values */
display: block flow;
display: inline table;
display: flex run-in;

/* <display-listitem> values */
display: list-item;
display: list-item block;
display: list-item inline;
display: list-item flow;
display: list-item flow-root;
display: list-item block flow;
display: list-item block flow-root;
display: flow list-item block;

/* <display-internal> values */
display: table-row-group;
display: table-header-group;
display: table-footer-group;
display: table-row;
display: table-cell;
display: table-column-group;
display: table-column;
display: table-caption;
display: ruby-base;
display: ruby-text;
display: ruby-base-container;
display: ruby-text-container;

/* <display-box> values */
display: contents;
display: none;

/* <display-legacy> values */
display: inline-block;
display: inline-table;
display: inline-flex;
display: inline-grid;

/* Global values */
display: inherit;
display: initial;
display: unset;

Initial valueinline
Applies toall elements
Inheritedno
Mediaall
Computed valueas the specified value, except for positioned and floating elements and the root element. In both cases the computed value may be a keyword other than the one specified.
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

The display property is specified using keyword values. Keyword values are grouped into six value categories:

<display-outside>
These keywords specify the element’s outer display type, which is essentially its role in flow layout.
<display-inside>
These keywords specify the element’s inner display type, which defines the type of formatting context that its contents are laid out in (assuming it is a non-replaced element).
<display-listitem>
The element generates a block box for the content and a separate list-item inline box.
<display-internal>
Some layout models such as table and ruby have a complex internal structure, with several different roles that their children and descendants can fill. This section defines those "internal" display values, which only have meaning within that particular layout mode.
<display-box>
These values define whether an element generates display boxes at all.
<display-legacy>
CSS 2 used a single-keyword syntax for the display property, requiring separate keywords for block-level and inline-level variants of the same layout mode.
<display-xul>  Deprecated since Gecko 62
Firefox only values used primarily for styling XUL documents.

"Legacy" values of display

The Level 3 specification details two values for the display property — enabling the specification of the outer and inner display type explicitly — but this is not yet well-supported by browsers.

The display-legacy methods allow the same results with single keyword values, and should be favoured by developers until the two keyword values are better supported. For example, using two values you might specify an inline flex container as follows:

.container {
    display: inline flex;
}

This can currently be specified using a single value.

.container {
    display: inline-flex;
}

Formal syntax

[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy>

where
<display-outside> = block | inline | run-in
<display-inside> = flow | flow-root | table | flex | grid | ruby
<display-listitem> = <display-outside>? && [ flow | flow-root ]? && list-item
<display-internal> = table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption | ruby-base | ruby-text | ruby-base-container | ruby-text-container
<display-box> = contents | none
<display-legacy> = inline-block | inline-list-item | inline-table | inline-flex | inline-grid

Examples

The individual pages for the different types of value that display can have set on it feature multiple examples of those values in action — see the Syntax section.

In addition, you can find detailed explanations of the layout models that certain values enable elsewhere on MDN:

Accessibility concerns

display: none;

Using a display value of none on an element will remove it from the accessibility tree. This will cause the element and all its descendant elements to no longer be announced by screen reading technology.

If you want to visually hide the element, a more accessible alternative is to use a combination of properties to remove it visually from the screen but keep it parseable by assistive technology such as screen readers.

display: contents;

Browsers will remove any element with a display value of contents set on it from the accessibility tree. This will cause the element and all its descendant elements to no longer be announced by screen reading technology.

Tables

Changing the display value of a table element to block, grid, or flex will alter its representation in the accessibility tree. This will cause the table to no longer be announced properly by screen reading technology. 

Specifications

Specification Status Comment
CSS Display Module Level 3
The definition of 'display' in that specification.
Working Draft Added run-in, flow, flow-root, contents, and multi-keyword values.
CSS Ruby Layout Module Level 1
The definition of 'display' in that specification.
Working Draft Added ruby, ruby-base, ruby-text, ruby-base-container, and ruby-text-container.
CSS Grid Layout
The definition of 'display' in that specification.
Candidate Recommendation Added the grid box model values.
CSS Flexible Box Layout Module
The definition of 'display' in that specification.
Candidate Recommendation Added the flexible box model values.
CSS Level 2 (Revision 1)
The definition of 'display' in that specification.
Recommendation Added the table model values and inline-block.
CSS Level 1
The definition of 'display' in that specification.
Recommendation Initial definition. Basic values: none, block, inline, and list-item.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support1121471
Multi-keyword values ? ? No No ? ?
list-item1121671
inline-block1121

8

61

71
inline-table1123871
table, table-cell, table-column, table-column-group, table-footer-group, table-header-group, table-row, and table-row-group1121871
flex

29

21 -webkit-

12

202

18 — 283

11

84

16

15 -webkit-

12.1 — 15

9

6.1 -webkit-

inline-flex

29

21 -webkit-

12

202

18 —?5

11

86

16

15 -webkit-

9

6.1 -webkit-

grid57

16

12 -ms-

5210 -ms- 744 Yes
inline-grid57

16

12 -ms-

5210 -ms- 744 ?
subgrid No No No No No No
ruby, ruby-base, ruby-base-container, ruby-text, and ruby-text-container ?12

38

34 — 388

? ? ?
run-in1 — 329 No No87 — 151 — 810
flow-root58 ?53 ?45 ?
contents

65

58 — 6511

No

37

36 — 5312

No5211.1
contents: Specific behavior of unusual elements when display: contents is applied to them ? No59 No No No
-moz-box and -moz-inline-box No No Yes13 No No No
-moz-grid, -moz-inline-grid, -moz-grid-group and -moz-grid-line No No Yes — 62 No No No
-moz-stack and -moz-inline-stack No No Yes — 62 No No No
-moz-deck No No Yes — 62 No No No
-moz-popup No No Yes — 62 No No No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes124 Yes Yes Yes
Multi-keyword values ? ? ? No ? ? ?
list-item Yes Yes124 Yes Yes Yes
inline-block Yes Yes124 Yes Yes Yes
inline-table Yes Yes124 Yes Yes Yes
table, table-cell, table-column, table-column-group, table-footer-group, table-header-group, table-row, and table-row-group Yes Yes124 Yes Yes Yes
flex

29

21 -webkit-

29

25 -webkit-

12

202

18 — 283

16

14 -webkit-

12.1 — 14

9

7.1 -webkit-

Yes
inline-flex

29

21 -webkit-

29

25 -webkit-

12

202

18 —?5

16

14 -webkit-

9

6.1 -webkit-

Yes
grid5757

16

12 -ms-

5244 Yes7.0
inline-grid5757

16

12 -ms-

5244 ?7.0
subgrid No No No No No No No
ruby, ruby-base, ruby-base-container, ruby-text, and ruby-text-container ? ?12

38

34 — 388

? ? ?
run-in Yes — 329 Yes — 329 No No ? Yes — 810 ?
flow-root5858 ?5345 ?7.0
contents6565 No575211.1 No
contents: Specific behavior of unusual elements when display: contents is applied to them ? ? No59 No No ?
-moz-box and -moz-inline-box No No No Yes13 No No No
-moz-grid, -moz-inline-grid, -moz-grid-group and -moz-grid-line No No No Yes — 62 No No No
-moz-stack and -moz-inline-stack No No No Yes — 62 No No No
-moz-deck No No No Yes — 62 No No No
-moz-popup No No No Yes — 62 No No No

1. Until Internet Explorer 8, inline-block is only for natural inline elements.

2. Firefox 28 added multi-line flexbox support.

3. From version 18 until version 28 (exclusive): this feature is behind the layout.css.flexbox.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

4. Supported as -ms-flexbox.

5. From version 18: this feature is behind the layout.css.flexbox.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

6. Supported as -ms-inline-flexbox.

7. Internet Explorer implements an older version of the specification.

8. From version 34 until version 38 (exclusive): this feature is behind the layout.css.ruby.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

9. Before Chrome 4, run-in was not supported before inline elements.

10. Before Safari 5, run-in was not supported before inline elements.

11. From version 58 until version 65 (exclusive): this feature is behind the Enable experimental Web Platform features preference. To change preferences in Chrome, visit chrome://flags.

12. From version 36 until version 53 (exclusive): this feature is behind the layout.css.display-contents.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

13. Scheduled for removal (See bug 879275).

See also