Revision 16599 of display

  • Revision slug: CSS/display
  • Revision title: display
  • Revision id: 16599
  • Created:
  • Creator: Dholbert
  • Is current revision? No
  • Comment For flexbox, use "display: flex | inline-flex" per current editor's draft at http://dev.w3.org/csswg/css3-flexbox/ (display:box is not supported anywhere. -webkit-box and -moz-box exist, but they're different and aren't intended to ever become an unprefi

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 child elements also have their display turned off. The document is rendered as though the element doesn't exist in the document tree.

  • {{ Xref_cssinitial() }}: inline
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified, except for root element, floated elements, and absolutely positioned elements

Syntax

display: display-value            or                           E.g. display: inline;
display: {{ Cssxref("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 child 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) table Behaves like the {{ HTMLElement("table") }} HTML element.
inline-table The inline-table value does not have a direct mapping in HTML.
table-caption Behaves like the {{ HTMLElement("caption") }} HTML element.
table-column These elements behave like the corresponding {{ HTMLElement("col") }} HTML elements.
table-colgroup These elements behave like the corresponding {{ HTMLElement("colgroup") }} HTML elements.
table-header-group These elements behave like the corresponding {{ HTMLElement("thead") }} HTML elements
table-row-group These elements behave like the corresponding  {{ HTMLElement("thead") }} HTML elements
table-footer-group These elements behave like the corresponding {{ HTMLElement("thead") }} HTML elements
table-row Behaves like the {{ HTMLElement("tr") }} HTML element
table-cell Behaves like the {{ HTMLElement("td") }} HTML element
Flexbox model values (CSS3) {{ experimental_inline() }} 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
CSS Grid model Level 3 {{ Spec2('CSS3 Grid') }} Added the grid box model values
CSS Flexible box model Level 3 {{ Spec2('CSS3 Flexbox') }} Added the flexible box model values
CSS 2.1 {{ Spec2('CSS2.1') }} Added the table model values and inline-block.
CSS 1 {{ 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 {{ non-standard_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)
box {{ experimental_inline() }} {{ CompatUnknown() }} {{ CompatNo() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
inline-box {{ experimental_inline() }} {{ CompatUnknown() }} {{ CompatNo() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
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() }}

See also

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

{{ languages( { "de": "de/CSS/display", "es": "es/CSS/display", "fr": "fr/CSS/display", "pl": "pl/CSS/display", "pt": "pt/CSS/display", "zh-cn": "cn/CSS/display" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2>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 child elements also have their display turned off. The document is rendered as though the element doesn't exist in the document tree.</p>
<nobr>
<ul class="cssprop"> <li><dfn>{{ Xref_cssinitial() }}:</dfn><code> inline</code></li> <li><dfn>Applies to:</dfn> all elements</li> <li><dfn>{{ Xref_cssinherited() }}:</dfn> no</li> <li><dfn>Media:</dfn> {{ Xref_cssvisual() }}</li> <li><dfn>{{ Xref_csscomputed() }}:</dfn> as specified, except for root element, <a href="/en/CSS/float" title="en/CSS/float">floated</a> elements, and <a href="/en/CSS/position" title="en/CSS/position">absolutely positioned</a> elements</li>
</ul>
</nobr>
<h2>Syntax</h2>
<pre class="eval syntaxbox">display: <em>display-value</em>       <em>     or                           E.g. </em>display: inline;
display: {{ Cssxref("inherit") }}
</pre>
<h3>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 child 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;"> </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>table</code></td> <td>Behaves like the {{ HTMLElement("table") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font>HTML element.</td> </tr> <tr> <td><code>inline-table</code></td> <td>The<code> inline-table </code>value does not have a direct mapping in HTML.</td> </tr> <tr> <td><code>table-caption</code></td> <td>Behaves like the {{ HTMLElement("caption") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font>HTML element.</td> </tr> <tr> <td><code>table-column</code></td> <td>These elements behave like the corresponding {{ HTMLElement("col") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font>HTML elements.</td> </tr> <tr> <td><code>table-colgroup</code></td> <td>These elements behave like the corresponding {{ HTMLElement("colgroup") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font>HTML elements.</td> </tr> <tr> <td><code>table-header-group</code></td> <td>These elements behave like the corresponding {{ HTMLElement("thead") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font>HTML elements</td> </tr> <tr> <td><code>table-row-group</code></td> <td>These elements behave like the corresponding<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace">  {{ HTMLElement("thead") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font></font>HTML elements</td> </tr> <tr> <td><code>table-footer-group</code></td> <td>These elements behave like the corresponding {{ HTMLElement("thead") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font>HTML elements</td> </tr> <tr> <td><code>table-row</code></td> <td>Behaves like the {{ HTMLElement("tr") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font>HTML element</td> </tr> <tr> <td><code>table-cell</code></td> <td>Behaves like the {{ HTMLElement("td") }}<font class="Apple-style-span" face="'Courier New', 'Andale Mono', monospace"> </font>HTML element</td> </tr> <tr> <td colspan="1" rowspan="2">Flexbox model values (<a href="/en/CSS/CSS3" title="CSS3">CSS3</a>) {{ experimental_inline() }}</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/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/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. <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"></a></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> <br>
</dl>
<dl> <dd>
</dd></dl>
<h3>Examples</h3>
<p>{{ CSSRefExampleLink("display") }}</p>
<pre>p.secret  { display: none }
&lt;p style="display:none"&gt; invisible text &lt;/p&gt;
</pre>
<h2 name="Browser_Compatibility">Specifications</h2>
<table class="standard-table"> <thead> <tr style="background-color: rgb(255, 204, 255);"> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td><a class="external" href="http://dev.w3.org/csswg/css3-grid-align/#grid-declaration" title="http://dev.w3.org/csswg/css3-grid-align/#grid-declaration">CSS Grid model Level 3</a></td> <td>{{ Spec2('CSS3 Grid') }}</td> <td>Added the grid box model values</td> </tr> <tr> <td><a class="external" href="http://dev.w3.org/csswg/css3-flexbox/#display-flexbox" title="http://dev.w3.org/csswg/css3-flexbox/#display-flexbox">CSS Flexible box model Level 3</a></td> <td>{{ Spec2('CSS3 Flexbox') }}</td> <td>Added the flexible box model values</td> </tr> <tr> <td><a class="external" href="http://www.w3.org/TR/CSS21/visuren.html#display" title="http://www.w3.org/TR/CSS21/visuren.html#display">CSS 2.1</a></td> <td>{{ Spec2('CSS2.1') }}</td> <td>Added the table model values and <code>inline-block<em>.</em></code></td> </tr> <tr> <td><a class="external" href="http://www.w3.org/TR/CSS1/#display" title="http://www.w3.org/TR/CSS1/#display">CSS 1</a></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 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> {{ non-standard_inline() }}</td> <td>1.0<br> Not before inline-elements</td> <td rowspan="2">{{ CompatNo() }} <a class="link-https" href="https://bugzilla.mozilla.org//show_bug.cgi?id=2056" title="https://bugzilla.mozilla.org//show_bug.cgi?id=2056"></a></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>box</code> {{ experimental_inline() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> <tr> <td><code>inline-box</code> {{ experimental_inline() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</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 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>
<h2>See also</h2>
<ul> <li>{{ Cssxref("visibility") }}, {{ Cssxref("float") }}, {{ Cssxref("position") }}</li>
</ul>
<p>{{ languages( { "de": "de/CSS/display", "es": "es/CSS/display", "fr": "fr/CSS/display", "pl": "pl/CSS/display", "pt": "pt/CSS/display", "zh-cn": "cn/CSS/display" } ) }}</p>
Revert to this revision