W3cubDocs

/CSS

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). These keywords are used as values of the display property, and can be used for legacy purposes as a single keyword, or as defined in the Level 3 specification alongside a value from the <display-outside> keywords.

Syntax

Valid <display-inside> values:

flow
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 position, float, or overflow) and whether it is itself participating in a block or inline formatting context, it either establishes a new block formatting context (BFC) for its contents or integrates its contents into its parent formatting context.

flow-root
The element generates a block element box that establishes a new block formatting context, defining where the formatting root lies.
table
These elements behave like HTML <table> 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.
ruby
The element behaves like an inline element and lays out its content according to the ruby formatting model. It behaves like the corresponding HTML <ruby> elements.

Note: Browsers that support the two value syntax, on finding the inner value only, such as when display: flex or display: grid is specified, will set their outer value to block. This will result in expected behavior; for example if you specify an element to be display: grid, you would expect that the box created on the grid container would be a block level box.

Examples

In this example the parent box has been given display: flow-root and so establishes a new BFC and contains the floated item.

HTML

<div class="box">
  <div class="float">I am a floated box!</div>
  <p>I am content inside the container.</p>
</div>

CSS

.box {
    background-color: rgb(224, 206, 247);
    border: 5px solid rebeccapurple;
    display: flow-root;
}

.float {
    float: left;
    width: 200px;
    height: 150px;
    background-color: white;
    border:1px solid black;
    padding: 10px;
}

Result

Specifications

Browser compatibilityUpdate compatibility data on GitHubUpdate compatibility data on GitHubUpdate compatibility data on GitHubUpdate compatibility data on GitHubUpdate compatibility data on GitHubUpdate compatibility data on GitHub

Support of multiple keyword values

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Multi-keyword values No No 70 No No No
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Multi-keyword values No No No No No No

Support of flow-root

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
flow-root 58 79 53 No 45 13
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
flow-root 58 58 53 43 13 7.0

Support of table

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
table, table-cell, table-column, table-column-group, table-footer-group, table-header-group, table-row, and table-row-group 1 12 1 8 7 1
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
table, table-cell, table-column, table-column-group, table-footer-group, table-header-group, table-row, and table-row-group ≤37 18 4 14 1 1.0

Legend

Full support

Support of grid

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
grid 57 16
16
12
Prefixed
Prefixed Implemented with the vendor prefix: -ms-
52 10
Prefixed
10
Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Internet Explorer implements an older version of the specification.
44 10.1
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
grid 57 57 52 43 10.3 6.0
6.0
Samsung Internet added this earlier than the corresponding Chrome version would indicate.

Legend

Full support
Partial support
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

Support of flex

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
flex 29
29
21
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
12 20
20
Firefox 28 added multi-line flexbox support.
18 — 28
Disabled
Disabled From version 18 until version 28 (exclusive): this feature is behind the layout.css.flexbox.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
11
11
IE incorrectly positions inline block content inside flex containers. See the discussion on Microsoft Answers.
8
IE incorrectly positions inline block content inside flex containers. See the discussion on Microsoft Answers.
Uses the non-standard name: -ms-flexbox
16
16
15
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
12.1 — 15
9
9
6.1
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
flex 4.4
4.4
≤37
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
29
29
25
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
20
20
Firefox 28 added multi-line flexbox support.
18 — 28
Disabled
Disabled From version 18 until version 28 (exclusive): this feature is behind the layout.css.flexbox.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
16
16
14
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
12.1 — 14
9
9
7
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
2.0
2.0
1.5
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-

Legend

Full support
Partial support
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.
Uses a non-standard name.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

Support of ruby

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
ruby, ruby-base, ruby-base-container, ruby-text, and ruby-text-container No 12 — 79 38
38
34 — 38
Disabled
Disabled From version 34 until version 38 (exclusive): this feature is behind the layout.css.ruby.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
7 No No
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
ruby, ruby-base, ruby-base-container, ruby-text, and ruby-text-container No No 38
38
34 — 38
Disabled
Disabled From version 34 until version 38 (exclusive): this feature is behind the layout.css.ruby.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No No No

Legend

Full support
No support
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

© 2005–2020 Mozilla and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/display-inside