--- title: display slug: Web/CSS/display tags: - CSS - CSS Display - Propriedade de CSS translation_of: Web/CSS/display ---
Esta propriedade display
de CSS especifica o tipo de caixa de renderização utilizado para um elemento. Em HTML, os valores da propriedade display
predefinidos têm o seu comportamento descrito nas especificações de HTML ou de uma folha de estilo predefinida do navegador ou do utilizador. O valor predefinido no XML é inline
, incluindo os elementos de SVG .
Em adição aos diferentes tipos de caixa de exibição, o valor none
deixa-o desativar a exibição de um elemento; quando utiliza none
, todos os elementos descendentes também têm as suas exibições desativadas. O documento é renderizado como se o elemento não existisse na árvore do documento.
/* <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;
{{cssinfo}}
A propriedade display
é especificada utilizando os valores chave. Os valores chave são agrupados em seis categorias:
<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.
<display-outside>
Valor | Descrição |
block |
The element generates a block element box. |
inline |
The element generates one or more inline element boxes. |
run-in {{experimental_inline}} |
The element generates a run-in box. Run-in elements act like inlines or blocks, depending on the surrounding elements. That is:
|
<display-inside>
Value | Description |
flow {{experimental_inline}} |
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 {{cssxref("position")}}, {{cssxref("float")}}, or {{cssxref("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 {{experimental_inline}} |
The element generates a block element box that establishes a new block formatting context. |
table |
These elements behave like {{HTMLElement("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 {{experimental_inline}} |
If the parent element has display:grid , the element itself and its content are laid out according to the grid model. |
ruby {{experimental_inline}} |
The element behaves like an inline element and lays out its content according to the ruby formatting model. It behaves like the corresponding {{HTMLElement("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.
Valor | Descrição |
table-row-group |
These elements behave like {{HTMLElement("tbody")}} HTML elements |
table-header-group |
These elements behave like {{HTMLElement("thead")}} HTML elements. |
table-footer-group |
These elements behave like {{HTMLElement("tfoot")}} HTML elements. |
table-row |
These elements behave like {{HTMLElement("tr")}} HTML elements. |
table-cell |
These elements behave like {{HTMLElement("td")}} HTML elements. |
table-column-group |
These elements behave like {{HTMLElement("colgroup")}} HTML elements. |
table-column |
These elements behave like {{HTMLElement("col")}} HTML elements. |
table-caption |
These elements behave like {{HTMLElement("caption")}} HTML elements. |
ruby-base {{experimental_inline}} |
These elements behave like {{HTMLElement("rb")}} elements. |
ruby-text {{experimental_inline}} |
These elements behave like {{HTMLElement("rt")}} elements. |
ruby-base-container {{experimental_inline}} |
These elements behave like {{HTMLElement("rbc")}} elements generated as anonymous boxes. |
ruby-text-container {{experimental_inline}} |
These elements behave like {{HTMLElement("rtc")}} elements. |
<display-box>
Valor | Descrição |
contents {{experimental_inline}} |
These elements don't produce a specific box by themselves. They are replaced by their pseudo-box and their child boxes. |
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 {{cssxref("visibility")}} property instead. |
<display-legacy>
display
property, requiring separate keywords for block-level and inline-level variants of the same layout mode. They are defined as follows:
Valor | Descrição |
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-table |
The It is equivalent to |
inline-flex |
The element behaves like an inline element and lays out its content according to the flexbox model. It is equivalent to |
inline-grid |
The element behaves like an inline element and lays out its content according to the grid model. |
<p>Visible text</p> <p class="secret">Invisible text</p>
p.secret { display: none; }
{{EmbedLiveSample("Hide_element", 300, 60)}}
Especificação | Estado | Comentário |
---|---|---|
{{SpecName('CSS3 Display', '#the-display-properties', 'display')}} | {{Spec2('CSS3 Display')}} | Added run-in , flow , flow-root , contents , and multi-keyword values. |
{{SpecName('CSS3 Ruby', '#ruby-display', 'display')}} | {{Spec2('CSS3 Ruby')}} | Added ruby , ruby-base , ruby-text , ruby-base-container , and ruby-text-container . |
{{SpecName('CSS3 Grid', '#grid-containers', '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')}} | Initial definition. Basic values: none , block , inline , and list-item . |
{{CompatibilityTable}}
Funcionalidade | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
none , inline and block |
1.0 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1.0")}} | 4.0 | 7.0 | 1.0 (85) |
inline-block |
1.0 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1.9")}} | 5.5[4] | 7.0 | 1.0 (85) |
list-item |
1.0 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1.0")}} | 6.0 | 7.0 | 1.0 (85) |
run-in {{experimental_inline}} |
1.0 [5] | {{CompatNo}} | {{CompatNo}} | 8.0 | 7.0 | 1.0 (85)[5] |
4.0 Removed in 32 | Not Blink versions (15 upwards) | 5.0 (532.5) Removed in 8.0 | ||||
inline-table |
1.0 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("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 , and table-caption |
1.0 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1.0")}} | 8.0 |
7.0 |
1.0 (85) |
flex |
21.0{{property_prefix("-webkit")}} 29.0 |
{{CompatVersionUnknown}} | {{CompatGeckoDesktop("18.0")}}[1] {{CompatGeckoDesktop("20.0")}} |
10{{property_prefix("-ms")}}[8] |
12.50 |
6.1{{property_prefix("-webkit")}} 9.0 |
inline-flex |
21.0{{property_prefix("-webkit")}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("18.0")}}[1] {{CompatGeckoDesktop("20.0")}} |
10{{property_prefix("-ms")}}[8] 11 |
12.50 | 6.1{{property_prefix("-webkit")}} |
grid {{experimental_inline}} |
{{CompatChrome(57)}} | {{CompatVersionUnknown}}{{property_prefix("-ms")}} | {{CompatGeckoDesktop("45.0")}}[6] | 10.0{{property_prefix("-ms")}} | {{CompatOpera(44)}} | TP |
inline-grid {{experimental_inline}} |
{{CompatChrome(57)}} | {{CompatVersionUnknown}}{{property_prefix("-ms")}} | {{CompatGeckoDesktop("45.0")}}[6] | 10.0{{property_prefix("-ms")}} | {{CompatOpera(44)}} | TP |
subgrid {{experimental_inline}} |
{{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} |
ruby , ruby-base , ruby-text , ruby-base-container , ruby-text-container {{experimental_inline}} |
{{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("34.0")}}[3] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
contents {{experimental_inline}} |
{{CompatChrome(58)}}[7] | {{CompatNo}} | {{CompatGeckoDesktop("37")}}[2] | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
flow-root |
{{CompatChrome(58)}} | {{CompatUnknown}} | {{CompatGeckoDesktop("53.0")}} | {{CompatUnknown}} | {{CompatOpera(45)}} | {{CompatUnknown}} |
Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | 7.0{{property_prefix("-webkit")}} |
grid {{experimental_inline}} |
{{CompatChrome(57)}} | {{CompatChrome(57)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOperaMobile(44)}} | {{CompatUnknown}} |
inline-grid {{experimental_inline}} |
{{CompatChrome(57)}} | {{CompatChrome(57)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOperaMobile(44)}} | {{CompatUnknown}} |
flow-root |
{{CompatChrome(58)}} | {{CompatChrome(58)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOperaMobile(45)}} | {{CompatUnknown}} |
[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] In IE < 8, natural inline elements only.
[5] Not before inline-elements.
[6] CSS Grid support is unprefixed in Nightly/Alpha builds and behind pref "layout.css.grid.enabled" in Beta/release builds.
[7] In Chrome, the contents
value is currently disabled by default, but can be enabled with the "Experimental Web Platform features" flag.
[8] In IE 10, only special prefixed values, -ms-flexbox
and -ms-inline-flexbox
, are recognized.
|
|
|
|
|
|
|
Opções : Histórico : Comentários : Donate | Encerrar |