MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 361307 of display

  • Revision slug: CSS/display
  • Revision title: display
  • Revision id: 361307
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{CSSRef}}

Summary

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.

{{cssbox("display")}}

Syntax

Formal syntax: {{csssyntax("display")}}
display: none
display: inline
display: block
display: list-item
display: inline-block
display: inline-table
display: table
display: table-cell
display: table-column
display: table-column-group
display: table-footer-group
display: table-header-group
display: table-row
display: table-row-group
display: flex
display: inline-flex
display: grid
display: inline-grid
display: run-in

display: inherit

Values

display-value

Is a keyword defining the rendering type to apply to the element. Its possible values and their meanings are:
Value set Value Description
Basic values (CSS 1) none

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

To render an element box's dimensions, yet have its contents be invisible, see the {{cssxref("visibility")}} property.

inline The element generates one or more inline element boxes.
block The element generates a block element box.
list-item The element generates a block box for the content and a separate list-item inline box.
Extended values (CSS 2.1) 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)
Table model values (CSS 2.1) inline-table The inline-table value does not have a direct mapping in HTML. It behaves like a {{HTMLElement("table")}} HTML element, but as an inline box, rather than a block-level box. Inside the table box is a block-level context.
table Behaves like the {{HTMLElement("table")}} HTML element. It defines a block-level box.
table-caption Behaves like the {{HTMLElement("caption")}} HTML element.
table-cell Behaves like the {{HTMLElement("td")}} HTML element
table-column These elements behave like the corresponding {{HTMLElement("col")}} HTML elements.
table-column-group These elements behave like the corresponding {{HTMLElement("colgroup")}} HTML elements.
table-footer-group These elements behave like the corresponding {{HTMLElement("tfoot")}} HTML elements
table-header-group These elements behave like the corresponding {{HTMLElement("thead")}} HTML elements
table-row Behaves like the {{HTMLElement("tr")}} HTML element
table-row-group These elements behave like the corresponding {{HTMLElement("tbody")}} HTML elements
Flexbox model values (CSS3) flex The element behaves like a block element and lays out its content according to the flexbox model.
inline-flex The element behaves like an inline element and lays out its content according to the flexbox model.
Grid box model values (CSS3) {{experimental_inline}} grid

The element behaves like a block element and lay out its content according to the grid model.

As this is experimental, most browsers don't support it. Especially pay attention that -moz-grid is not the prefixed version of this, but a XUL layout model that must not be used on a Web site.
inline-grid The element behaves like an inline element and lay out its content according to the grid model.
Experimental values {{experimental_inline}} run-in
  • 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 a inline box follows, the run-in box becomes a block box.

Examples

{{CSSRefExampleLink("display")}}

p.secret  { display: none }
<p style="display:none"> invisible text </p>

Specifications

Specification Status Comment
{{SpecName('CSS3 Box', '#display', 'display')}} {{Spec2('CSS3 Box')}} Added the run-in value.
{{SpecName('CSS3 Grid', '#grid-declaration0', 'display')}} {{Spec2('CSS3 Grid')}} Added the grid box model values.
{{SpecName('CSS3 Flexbox', '#flex-containers', 'display')}} {{Spec2('CSS3 Flexbox')}} Added the flexible box model values.
{{SpecName('CSS2.1', 'visuren.html#display-prop', 'display')}} {{Spec2('CSS2.1')}} Added the table model values and inline-block.
{{SpecName('CSS1', '#display', 'display')}} {{Spec2('CSS1')}} Basic values: none, block, inline, and list-item.

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
none, inline and block 1.0 1.0 (1.0) 4.0 7.0 1.0 (85)
inline-block 1.0 3.0 (1.9) 5.5 (-7.0)
natural inline elements only
7.0 1.0 (85)
list-item 1.0 1.0 (1.0) 6.0 7.0 1.0 (85)
run-in {{experimental_inline}} 1.0
Not before inline-elements
{{CompatNo}} 8.0 7.0 1.0 (85)
Not before inline-elements
4.0 5.0 (532.5)
inline-table 1.0 3.0 (1.9) 8.0 7.0 1.0 (85)
table, table-cell, table-column, table-colgroup, table-header-group, table-row-group, table-footer-group, table-row, and table-caption 1.0 1.0 (1.0) 8.0 7.0 1.0 (85)
flex 21.0{{property_prefix("-webkit")}} {{CompatGeckoDesktop("18.0")}}(behind a pref) [1]
{{CompatGeckoDesktop("20.0")}}
{{CompatNo}} 12.50 {{CompatNo}}
inline-flex 21.0{{property_prefix("-webkit")}} {{CompatGeckoDesktop("18.0")}}(behind a pref) [1]
{{CompatGeckoDesktop("20.0")}}
{{CompatNo}} 12.50 {{CompatNo}}
grid {{experimental_inline}} {{CompatUnknown}} {{CompatNo}} 10.0 {{CompatUnknown}} {{CompatUnknown}}
inline-grid {{experimental_inline}} {{CompatUnknown}} {{CompatNo}} 10.0 {{CompatUnknown}} {{CompatUnknown}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

[1] Firefox supports only single-line flexbox. To activate flexbox support, for Firefox 18 and 19, the user has to change the about:config preference "layout.css.flexbox.enabled" to true.

See also

  • {{Cssxref("visibility")}}, {{Cssxref("float")}}, {{Cssxref("position")}}

Revision Source

<div>
  {{CSSRef}}</div>
<h2 id="Summary">Summary</h2>
<p>The <code>display</code> CSS property specifies the type of rendering box used for an element. In HTML, default <code>display</code> property values are taken from behaviors described in the HTML specifications or from the browser/user default stylesheet. The default value in XML is <code>inline</code>.</p>
<p>In addition to the many different display box types, the value <code>none</code> lets you turn off the display of an element; when you use <code>none</code>, all descendant elements also have their display turned off. The document is rendered as though the element doesn't exist in the document tree.</p>
<p>{{cssbox("display")}}</p>
<h2 id="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("display")}}
</pre>
<pre>
display: none
display: <span id="syntax-display"><code>inline
display: block
display: list-item
display: inline-block
display: inline-table
display: table
display: table-cell
display: table-column
display: table-column-group
display: table-footer-group
display: table-header-group
display: table-row
display: table-row-group
display: flex
display: inline-flex
display: grid
display: inline-grid
display: run-in</code></span>

display: inherit
</pre>
<h3 id="Values">Values</h3>
<p><em><strong>display-value</strong></em></p>
<dl>
  <dd>
    Is a keyword defining the rendering type to apply to the element. Its possible values and their meanings are:<br />
    <table class="standard-table">
      <thead>
        <tr>
          <td class="header" colspan="1">Value set</td>
          <td class="header">Value</td>
          <td class="header">Description</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td colspan="1" rowspan="4">Basic values (CSS 1)</td>
          <td><code>none</code></td>
          <td>
            <p>Turns off the display of an element (it has no effect on layout); all descendant elements also have their display turned off. The document is rendered as though the element did not exist.</p>
            <p>To render an element box's dimensions, yet have its contents be invisible, see the {{cssxref("visibility")}} property.</p>
          </td>
        </tr>
        <tr>
          <td><code>inline</code></td>
          <td>The element gener<span id="cke_bm_280S" style="display: none;">&nbsp;</span>ates one or more inline element boxes.</td>
        </tr>
        <tr>
          <td><code>block</code></td>
          <td>The element generates a block element box.</td>
        </tr>
        <tr>
          <td><code>list-item</code></td>
          <td>The element generates a block box for the content and a separate list-item inline box.</td>
        </tr>
        <tr>
          <td>Extended values (CSS 2.1)</td>
          <td><code>inline-block</code></td>
          <td>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)</td>
        </tr>
        <tr>
          <td colspan="1" rowspan="10">Table model values (CSS 2.1)</td>
          <td><code>inline-table</code></td>
          <td>The<code> inline-table </code>value does not have a direct mapping in HTML. It behaves like a {{HTMLElement("table")}} HTML element, but as an inline box, rather than a block-level box. Inside the table box is a block-level context.</td>
        </tr>
        <tr>
          <td><code>table</code></td>
          <td>Behaves like the {{HTMLElement("table")}} HTML element. It defines a block-level box.</td>
        </tr>
        <tr>
          <td><code>table-caption</code></td>
          <td>Behaves like the {{HTMLElement("caption")}} HTML element.</td>
        </tr>
        <tr>
          <td><code>table-cell</code></td>
          <td>Behaves like the {{HTMLElement("td")}} HTML element</td>
        </tr>
        <tr>
          <td><code>table-column</code></td>
          <td>These elements behave like the corresponding {{HTMLElement("col")}} HTML elements.</td>
        </tr>
        <tr>
          <td><code>table-column-group</code></td>
          <td>These elements behave like the corresponding {{HTMLElement("colgroup")}} HTML elements.</td>
        </tr>
        <tr>
          <td><code>table-footer-group</code></td>
          <td>These elements behave like the corresponding&nbsp;{{HTMLElement("tfoot")}} HTML elements</td>
        </tr>
        <tr>
          <td><code>table-header-group</code></td>
          <td>These elements behave like the corresponding {{HTMLElement("thead")}} HTML elements</td>
        </tr>
        <tr>
          <td><code>table-row</code></td>
          <td>Behaves like the {{HTMLElement("tr")}} HTML element</td>
        </tr>
        <tr>
          <td><code>table-row-group</code></td>
          <td>These elements behave like the corresponding {{HTMLElement("tbody")}} HTML elements</td>
        </tr>
        <tr>
          <td colspan="1" rowspan="2">Flexbox model values (<a href="/en-US/docs/CSS/CSS3" title="CSS3">CSS3</a>)</td>
          <td><code>flex</code></td>
          <td>The element behaves like a block element and lays out its content according to the flexbox model.</td>
        </tr>
        <tr>
          <td><code>inline-flex</code></td>
          <td>The element behaves like an inline element and lays out its content according to the flexbox model.</td>
        </tr>
        <tr>
          <td colspan="1" rowspan="2">Grid box model values (<a href="/en-US/docs/CSS/CSS3" title="CSS3">CSS3</a>) {{experimental_inline}}</td>
          <td><code>grid</code></td>
          <td>
            <p>The element behaves like a block element and lay out its content according to the grid model.</p>
            <div class="note">
              As this is experimental, <a href="/en-US/docs/CSS/display#Browser_Compatibility" title="https://developer.mozilla.org/en/CSS/display#Browser_Compatibility">most browsers don't support it</a>. Especially pay attention that <code>-moz-grid</code> is not the prefixed version of this, but a <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=616605#c10" title="https://bugzilla.mozilla.org/show_bug.cgi?id=616605#c10">XUL layout model</a> that must not be used on a Web site.</div>
          </td>
        </tr>
        <tr>
          <td><code>inline-grid</code></td>
          <td>The element behaves like an inline element and lay out its content according to the grid model.</td>
        </tr>
        <tr>
          <td>Experimental values {{experimental_inline}}</td>
          <td><code>run-in</code></td>
          <td>
            <ul>
              <li>If the run-in box contains a block box, same as block.</li>
              <li>If a block box follows the run-in box, the run-in box becomes the first inline box of the block box.</li>
              <li>If a inline box follows, the run-in box becomes a block box.</li>
            </ul>
          </td>
        </tr>
      </tbody>
    </table>
  </dd>
</dl>
<h2 id="Examples">Examples</h2>
<p>{{CSSRefExampleLink("display")}}</p>
<pre class="brush: css">
p.secret  { display: none }
&lt;p style="display:none"&gt; invisible text &lt;/p&gt;
</pre>
<h2 id="Browser_Compatibility" name="Browser_Compatibility">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{SpecName('CSS3 Box', '#display', 'display')}}</td>
      <td>{{Spec2('CSS3 Box')}}</td>
      <td>Added the <code>run-in</code> value.</td>
    </tr>
    <tr>
      <td>{{SpecName('CSS3 Grid', '#grid-declaration0', 'display')}}</td>
      <td>{{Spec2('CSS3 Grid')}}</td>
      <td>Added the grid box model values.</td>
    </tr>
    <tr>
      <td>{{SpecName('CSS3 Flexbox', '#flex-containers', 'display')}}</td>
      <td>{{Spec2('CSS3 Flexbox')}}</td>
      <td>Added the flexible box model values.</td>
    </tr>
    <tr>
      <td>{{SpecName('CSS2.1', 'visuren.html#display-prop', 'display')}}</td>
      <td>{{Spec2('CSS2.1')}}</td>
      <td>Added the table model values and <code>inline-block<em>.</em></code></td>
    </tr>
    <tr>
      <td>{{SpecName('CSS1', '#display', 'display')}}</td>
      <td>{{Spec2('CSS1')}}</td>
      <td>Basic values: <code>none</code>, <code>block</code>, <code>inline</code>, and <code>list-item</code>.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td><code>none</code>, <code>inline</code> and <code>block</code></td>
        <td>1.0</td>
        <td>1.0 (1.0)</td>
        <td>4.0</td>
        <td>7.0</td>
        <td>1.0 (85)</td>
      </tr>
      <tr>
        <td><code>inline-block</code></td>
        <td>1.0</td>
        <td>3.0 (1.9)</td>
        <td>5.5 (-7.0)<br />
          natural inline elements only</td>
        <td>7.0</td>
        <td>1.0 (85)</td>
      </tr>
      <tr>
        <td><code>list-item</code></td>
        <td>1.0</td>
        <td>1.0 (1.0)</td>
        <td>6.0</td>
        <td>7.0</td>
        <td>1.0 (85)</td>
      </tr>
      <tr>
        <td rowspan="2"><code>run-in</code> {{experimental_inline}}</td>
        <td>1.0<br />
          Not before inline-elements</td>
        <td rowspan="2">{{CompatNo}}</td>
        <td rowspan="2">8.0</td>
        <td rowspan="2">7.0</td>
        <td>1.0 (85)<br />
          Not before inline-elements</td>
      </tr>
      <tr>
        <td>4.0</td>
        <td>5.0 (532.5)</td>
      </tr>
      <tr>
        <td><code>inline-table</code></td>
        <td>1.0</td>
        <td>3.0 (1.9)</td>
        <td>8.0</td>
        <td>7.0</td>
        <td>1.0 (85)</td>
      </tr>
      <tr>
        <td><code>table</code>, <code>table-cell</code>, <code>table-column</code>, <code>table-colgroup</code>, <code>table-header-group</code>, <code>table-row-group</code>, <code>table-footer-group</code>, <code>table-row</code>, and <code>table-caption</code></td>
        <td>1.0</td>
        <td>1.0 (1.0)</td>
        <td>8.0</td>
        <td>7.0</td>
        <td>1.0 (85)</td>
      </tr>
      <tr>
        <td><code>flex</code></td>
        <td>21.0{{property_prefix("-webkit")}}</td>
        <td>{{CompatGeckoDesktop("18.0")}}(behind a pref) [1]<br />
          {{CompatGeckoDesktop("20.0")}}</td>
        <td>{{CompatNo}}</td>
        <td>12.50</td>
        <td>{{CompatNo}}</td>
      </tr>
      <tr>
        <td><code>inline-flex</code></td>
        <td>21.0{{property_prefix("-webkit")}}</td>
        <td>{{CompatGeckoDesktop("18.0")}}(behind a pref) [1]<br />
          {{CompatGeckoDesktop("20.0")}}</td>
        <td>{{CompatNo}}</td>
        <td>12.50</td>
        <td>{{CompatNo}}</td>
      </tr>
      <tr>
        <td><code>grid</code> {{experimental_inline}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatNo}}</td>
        <td>10.0</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>inline-grid</code> {{experimental_inline}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatNo}}</td>
        <td>10.0</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE&nbsp;Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<p>[1] Firefox supports only single-line flexbox. To activate flexbox support, for Firefox 18 and 19, the user has to change the about:config preference "layout.css.flexbox.enabled" to <code>true</code>.</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{Cssxref("visibility")}}, {{Cssxref("float")}}, {{Cssxref("position")}}</li>
</ul>
Revert to this revision