The display CSS property specifies the type of rendering box used for an element. In HTML, default display property values are taken from behaviors described in the HTML specifications or from the browser/user default stylesheet. The default value in XML is inline, including SVG elements.

In addition to the many different display box types, the value none lets you turn off the display of an element; when you use none, all descendant elements also have their display turned off. The document is rendered as though the element doesn't exist in the document tree.

/* <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: subgrid;

/* <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 categories:

Currently it's best to specify display using a single keyword; although the latest specifications allow you to combine some keywords, this is not yet well supported by browsers.

Values

<display-outside>
These keywords specify the element’s outer display type, which is essentially its role in flow layout. They are defined as follows:
Value Description
block The element generates a block element box.
inline The element generates one or more inline element boxes.
run-in The element generates a run-in box. Run-in elements act like inlines or blocks, depending on the surrounding elements. That is:
  • If the run-in box contains a block box, same as block.
  • If a block box follows the run-in box, the run-in box becomes the first inline box of the block box.
  • If an inline box follows, the run-in box becomes a block box.
<display-inside>
These keywords specify the element’s inner display type, which defines the type of formatting context that lays out its contents (assuming it is a non-replaced element). They are defined as follows:
Value Description
flow The element lays out its contents using flow layout (block-and-inline layout).

If its outer display type is inline or run-in, and it is participating in a block or inline formatting context, then it generates an inline box. Otherwise it generates a block container box.

Depending on the value of other properties (such as position, float, or overflow) and whether it is itself participating in a block or inline formatting context, it either establishes a new block formatting context for its contents or integrates its contents into its parent formatting context.

flow-root The element generates a block element box that establishes a new block formatting context.
table These elements behave like <table> HTML elements. It defines a block-level box.
flex The element behaves like a block element and lays out its content according to the flexbox model.
grid The element behaves like a block element and lays out its content according to the grid model.
subgrid If the parent element has display:grid, the element itself and its content are laid out according to the grid model.
ruby The element behaves like an inline element and lays out its content according to the ruby formatting model. It behaves like the corresponding <ruby> HTML elements.
<display-listitem>

The element generates a block box for the content and a separate list-item inline box.

If no <display-inside> value is specified, the principal box’s inner display type defaults to flow. If no <display-outside> value is specified, the principal box’s outer display type defaults to block.

<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.

Unless otherwise specified, both the inner display type and the outer display type of elements using these display values are set to the given keyword.

Value Description
table-row-group These elements behave like <tbody> HTML elements
table-header-group These elements behave like <thead> HTML elements.
table-footer-group These elements behave like <tfoot> HTML elements.
table-row These elements behave like <tr> HTML elements.
table-cell These elements behave like <td> HTML elements.
table-column-group These elements behave like <colgroup> HTML elements.
table-column These elements behave like <col> HTML elements.
table-caption These elements behave like <caption> HTML elements.
ruby-base These elements behave like <rb> elements.
ruby-text These elements behave like <rt> elements.
ruby-base-container These elements behave like <rbc> elements generated as anonymous boxes.
ruby-text-container These elements behave like <rtc> elements.
<display-box>
These values define whether an element generates display boxes at all.
Value Description
contents These elements don't produce a specific box by themselves. They are replaced by their pseudo-box and their child boxes. Please note that CSS Display Level 3 spec defines how the contents value should affect "unusual elements" — elements that aren’t rendered purely by CSS box concepts such as replaced elements. See Appendix B: Effects of display: contents on Unusual Elements for more details.
none

Turns off the display of an element so that it has no effect on layout (the document is rendered as though the element did not exist). All descendant elements also have their display turned off.

To have an element take up the space that it would normally take, but without actually rendering anything, use the visibility property instead.

<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. They are defined as follows:
Value Description
inline-block

The element generates a block element box that will be flowed with surrounding content as if it were a single inline box (behaving much like a replaced element would)

It is equivalent to inline flow-root.

inline-table

The inline-table value does not have a direct mapping in HTML. It behaves like a <table> HTML element, but as an inline box, rather than a block-level box. Inside the table box is a block-level context.

It is equivalent to inline table.

inline-flex

The element behaves like an inline element and lays out its content according to the flexbox model.

It is equivalent to inline flex.

inline-grid The element behaves like an inline element and lays out its content according to the grid model.

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 | subgrid | ruby
<display-listitem> = list-item && <display-outside>? && [ flow | flow-root ]?
<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

Hide element

HTML

<p>Visible text</p>
<p class="secret">Invisible text</p>

CSS

p.secret {
  display: none;
}

Result

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.

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
list-item1121671
inline-block11216171
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 —?3

11

84

Yes

9

6.1 -webkit-

inline-flex21 -webkit- 12

202

18 —?3

11

85

Yes6.1 -webkit-
grid57

16

12 -ms-

5210 -ms- 44 ?
inline-grid5712 -ms- 5210 -ms- 44 ?
subgrid ? No ? No ? ?
ruby, ruby-base, ruby-base-container, ruby-text, and ruby-text-container ?12346 ? ? ?
run-in1 — 327 No No87 — 151 — 88
flow-root58 ?53 ?45 ?
contents

65

58 — 659

No

37

Yes — 5310

No5211.1
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes Yes Yes Yes Yes
list-item ? ? ? ? ? ? ?
inline-block ? ? ? ? ? ? ?
inline-table ? ? ? ? ? ? ?
table, table-cell, table-column, table-column-group, table-footer-group, table-header-group, table-row, and table-row-group ? ? ? ? ? ? ?
flex ? ? ? ? ? ? ?
inline-flex ? ? ? ? ? ? ?
grid5757 ?5244 ?7.0
inline-grid5757 ?5244 ?7.0
subgrid ? ? ? ? ? ? ?
ruby, ruby-base, ruby-base-container, ruby-text, and ruby-text-container ? ? ? ? ? ? ?
run-in ? ? ? ? ? ? ?
flow-root5858 ? ?45 ?7.0
contents6565 ?575211.1 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: 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. Supported as -ms-inline-flexbox.

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

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

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

9. 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.

10. 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.

See also