mozilla

Revision 16586 of display

  • Revision slug: CSS/display
  • Revision title: display
  • Revision id: 16586
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 66 words added, 1 words removed

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 allows the display of an element to be turned off; all child elements also have their display turned off. The document is rendered as though the element did not 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 value and their meaning are:
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 <table> HTML element.
inline-table The inline-table value does not have a direct mapping in HTML.
table-caption Behaves like the <caption> HTML element.
table-column These elements behave like the corresponding <col> HTML elements.
table-colgroup These elements behave like the corresponding  <colgroup> HTML elements.
table-header-group These elements behave like the corresponding <thead> HTML elements
table-row-group These elements behave like the corresponding <thead> HTML elements
table-footer-group These elements behave like the corresponding <thead> HTML elements
table-row Behaves like the <tr> HTML element
table-cell Behaves like the <td> HTML element
Flex box model values (CSS3) {{ experimental_inline() }} flexbox The element behaves like a block element and lay out its content according to the flexbox model.
inline-flexbox The element behaves like an inline element and lay 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.
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>

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)
flexbox {{ experimental_inline() }}          
inline-flexbox {{ experimental_inline() }}          

grid {{ experimental_inline() }}

         

inline-grid {{ experimental_inline() }}

         
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

Specifications

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> allows the display of an element to be turned off; all child elements also have their display turned off. The document is rendered as though the element did not exist in the document tree.</p>
<ul class="cssprop"> <li>{{ Xref_cssinitial() }}:<code> inline</code></li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: 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>
<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 value and their meaning are:<br> <table class="standard-table"> <tbody> <tr> <td colspan="1" rowspan="4">Basic values (CSS 1)</td> <td><code>none</code></td> <td>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.<br> To render an element box's dimensions, yet have its contents be invisible, see the {{ cssxref("visibility") }} property.</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<code> &lt;table&gt; </code>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<code> &lt;caption&gt; </code>HTML element.</td> </tr> <tr> <td><code>table-column</code></td> <td>These elements behave like the corresponding<code> &lt;col&gt; </code>HTML elements.</td> </tr> <tr> <td><code>table-colgroup</code></td> <td>These elements behave like the corresponding<code> </code><code> &lt;colgroup&gt; </code>HTML elements.</td> </tr> <tr> <td><code>table-header-group</code></td> <td>These elements behave like the corresponding<code> &lt;thead&gt; </code>HTML elements</td> </tr> <tr> <td><code>table-row-group</code></td> <td>These elements behave like the corresponding<code> &lt;thead&gt; </code>HTML elements</td> </tr> <tr> <td><code>table-footer-group</code></td> <td>These elements behave like the corresponding<code> &lt;thead&gt; </code>HTML elements</td> </tr> <tr> <td><code>table-row</code></td> <td>Behaves like the<code> &lt;tr&gt; </code>HTML element</td> </tr> <tr> <td><code>table-cell</code></td> <td>Behaves like the<code> &lt;td&gt; </code>HTML element</td> </tr> <tr> <td colspan="1" rowspan="2">Flex box model values (CSS3) {{ experimental_inline() }}</td> <td><code>flexbox</code></td> <td>The element behaves like a block element and lay out its content according to the flexbox model.</td> </tr> <tr> <td><code>inline-flexbox</code></td> <td>The element behaves like an inline element and lay out its content according to the flexbox model.</td> </tr> <tr> <td colspan="1" rowspan="2">Grid box model values (CSS3) {{ experimental_inline() }}</td> <td><code>grid</code></td> <td>The element behaves like a block element and lay out its content according to the grid model.</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">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() }} </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>flexbox</code> {{ experimental_inline() }}</td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><code>inline-flexbox</code> {{ experimental_inline() }}</td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> <p><code>grid</code> {{ experimental_inline() }}</p> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> <p><code>inline-grid</code> {{ experimental_inline() }}</p> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </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>Specifications</h2>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS21/visuren.html#display-prop">CSS 2.1 Visual formatting #display</a></li>
</ul>
<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