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.
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-list-item; display: inline-table; display: inline-flex; display: inline-grid; /* Global values */ display: inherit; display: initial; display: unset;
| Initial value | inline | 
|---|---|
| Applies to | all elements | 
| Inherited | no | 
| Media | all | 
| Computed value | as 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 type | discrete | 
| Canonical order | the 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:
- <display-outside>
- <display-inside>
- <display-listitem>
- <display-internal>
- <display-box>
- <display-legacy>
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 blockThe element generates a block element box. inlineThe element generates one or more inline element boxes. run-inThe 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 flowThe 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, oroverflow) 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-rootThe element generates a block element box that establishes a new block formatting context. tableThese elements behave like <table>HTML elements. It defines a block-level box.flexThe element behaves like a block element and lays out its content according to the flexbox model. -webkit-flexAlias for flex.-moz-box/-webkit-boxThe element behaves like a flexible box according to an outdated Flexbox specification. gridThe element behaves like a block element and lays out its content according to the grid model. subgridIf the parent element has display:grid, the element itself and its content are laid out according to the grid model.rubyThe 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 toflow. If no<display-outside>value is specified, the principal box’s outer display type defaults toblock.
- <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-groupThese elements behave like <tbody>HTML elementstable-header-groupThese elements behave like <thead>HTML elements.table-footer-groupThese elements behave like <tfoot>HTML elements.table-rowThese elements behave like <tr>HTML elements.table-cellThese elements behave like <td>HTML elements.table-column-groupThese elements behave like <colgroup>HTML elements.table-columnThese elements behave like <col>HTML elements.table-captionThese elements behave like <caption>HTML elements.ruby-baseThese elements behave like <rb>elements.ruby-textThese elements behave like <rt>elements.ruby-base-containerThese elements behave like <rbc>elements generated as anonymous boxes.ruby-text-containerThese elements behave like <rtc>elements.
- <display-box>
- These values define whether an element generates display boxes at all.
 Value Description contentsThese elements don't produce a specific box by themselves. They are replaced by their pseudo-box and their child boxes. noneTurns 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 visibilityproperty instead.
- <display-legacy>
- CSS 2 used a single-keyword syntax for the displayproperty, requiring separate keywords for block-level and inline-level variants of the same layout mode. They are defined as follows:Value Description inline-blockThe 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-list-itemThis value makes the element a list item, with the effects described above. Additionally, the outsidevalue oflist-style-positioncomputes toinsideon this element. Otherwise, this display value is treated identically to inline.inline-tableThe inline-tablevalue 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-flexThe element behaves like an inline element and lays out its content according to the flexbox model. It is equivalent to inline flex.-webkit-inline-flexAlias for inline-flex.-moz-inline-box/-webkit-inline-boxThe element behaves like a inline flexible box according to an outdated Flexbox specification. inline-gridThe 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 content
<p>Visible text</p> <p class="secret">Invisible text</p>
CSS content
p.secret {
  display: none;
}
Result
Specifications
Browser compatibility
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) | 
|---|---|---|---|---|---|---|
| none,inlineandblock | 1.0 | (Yes) | 1.0 (1.7 or earlier) | 4.0 | 7.0 | 1.0 (85) | 
| inline-block | 1.0 | (Yes) | 3.0 (1.9) | 5.5[4] | 7.0 | 1.0 (85) | 
| list-item | 1.0 | (Yes) | 1.0 (1.7 or earlier) | 6.0 | 7.0 | 1.0 (85) | 
| inline-list-item | No support | No support | No support[6] | No support | No support | No support | 
| run-in | 1.0 [5] | (Yes) | No support | 8.0 | 7.0 | 1.0 (85)[5] | 
| 4.0 Removed in 32 | 5.0 (532.5) Removed in 8.0 | |||||
| inline-table | 1.0 | (Yes) | 3.0 (1.9) | 8.0 | 7.0 | 1.0 (85) | 
| table,table-cell,table-column,table-column-group,table-header-group,table-row-group,table-footer-group,table-row, andtable-caption | 1.0 | (Yes) | 1.0 (1.7 or earlier) | 8.0 | 7.0 | 1.0 (85) | 
| flex | 21.0-webkit | (Yes) | 18.0 (18.0)[1] 20.0 (20.0) | 11 | 12.50 | 6.1-webkit | 
| inline-flex | 21.0-webkit | (Yes) | 18.0 (18.0)[1] 20.0 (20.0) | 11 | 12.50 | 6.1-webkit | 
| grid | 57 | (Yes)-ms | 45.0 (45.0)[7] | 10.0-ms | 44 | TP | 
| inline-grid | 57 | (Yes)-ms | 45.0 (45.0)[7] | 10.0-ms | 44 | TP | 
| subgrid | ? | No support | ? | No support | ? | ? | 
| ruby,ruby-base,ruby-text,ruby-base-container,ruby-text-container | ? | (Yes) | 34.0 (34.0)[3] | ? | ? | ? | 
| contents | 58[8] | No support | 37 (37)[2] | No support | No support | No support | 
| -webkit-box | (Yes) | ? | 45.0 (45.0) | No support | (Yes) | ? | 
| -webkit-inline-box | (Yes) | ? | 48.0 (48.0) | No support | (Yes) | ? | 
| -webkit-flex,-webkit-inline-flex | (Yes) | ? | 48.0 (48.0) | No support | (Yes) | ? | 
| flow-root | 58 | ? | 53.0 (53.0) | ? | 45 | ? | 
| Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | 
|---|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | ? | ? | (Yes) | 7.0-webkit | 
| grid | 57 | 57 | ? | ? | ? | 44 | ? | 
| inline-grid | 57 | 57 | ? | ? | ? | 44 | ? | 
| flow-root | 58 | 58 | ? | ? | ? | 45 | ? | 
[1] To activate flexbox support, for Firefox 18 and 19, the user has to change the about:config preference "layout.css.flexbox.enabled" to true. Multi-line flexbox are supported since Firefox 28.
[2] Before Firefox 37, the contents value was disabled by default, and could be enabled by setting the layout.css.display-contents.enabled pref to true. In Firefox 37, it was enabled by default, and in Firefox 53 the pref was removed altogether.
[3] CSS Ruby support is behind pref "layout.css.ruby.enabled". The user has to change this pref to true to activate this.
[4] Natural inline elements only.
[5] Not before inline-elements.
[6] See bug 1105868.
[7] CSS Grid support is unprefixed in Nightly/Alpha builds and behind pref "layout.css.grid.enabled" in Beta/release builds.
[8] In Chrome, the contents value is currently disabled by default, but can be enabled with the "Experimental Web Platform features" flag.