Working Draft · css-display

CSS Display

5 properties, 6 types defined by this specification, all known to at least one browser .

Each feature in detail

display

MDN The display CSS property sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex.

Live preview Example from MDN
.example-container {
  width: 100%;
  height: 100%;
}

code {
  background: #88888888;
}

#example-element {
  border: 3px dashed orange;
}

.child {
  display: inline-block;
  padding: 0.5em 1em;
  background-color: #ccccff;
  border: 1px solid #ababab;
  color: black;
}

Syntax

[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy> | grid-lanes | inline-grid-lanes | <display-outside> || [ <display-inside> | math ]

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
inline
Applies to
all elements
Inherited
no
Percentages
n/a
Computed value
a pair of keywords representing the inner and outer display types plus optional list-item flag, or a <display-internal> or <display-box> keyword; see prose in a variety of specs for computation rules
Canonical order
per grammar
Animation type
see § 2.9 Animating and Interpolating display

Browser support

First browser version supporting display
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

order

Property Baseline: widely availablesince March 2018

MDN The order CSS property sets the order to lay out an item in a flex or grid container. Items in a container are sorted by ascending order value and then by their source code order. Items not given an explicit order value are assigned the default value of 0.

Live preview Example from MDN
.default-example {
  max-height: 300px;
  display: flex;
  flex-flow: column;
}

.default-example > div {
  background-color: rgb(0 0 255 / 0.2);
  border: 3px solid blue;
  margin: 0.5rem;
  padding: 0.5rem;
  flex: 1;
}

#example-element {
  background-color: rgb(255 0 200 / 0.2);
  border: 3px solid rebeccapurple;
}

#example-element::after {
  content: attr(style);
  outline: 2px dashed;
  font-family: monospace;
}

Syntax

<integer>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
0
Applies to
flex items and grid items
Inherited
no
Percentages
n/a
Computed value
specified integer
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting order
Chrome 29
Edge 12
Firefox 20
Safari 9
Chrome Android 29
Safari iOS 9

First version with support, from MDN browser-compat-data.

reading-flow

Property Limited availability Experimental Modern CSS: reading-flow

MDN The reading-flow CSS property enables modifying the reading order of child elements of a block, flex, or grid layout. This affects the order in which they are rendered to speech and navigated to when using sequential navigation such as tabbing to links or buttons.

Live preview Example from MDN
.wrapper {
  display: flex;
  flex-direction: row-reverse;
  reading-flow: normal;
  gap: 1em;
}

a:first-child {
  order: 1;
}

Syntax

normal | source-order | flex-visual | flex-flow | grid-rows | grid-columns | grid-order

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
normal
Applies to
block, flex and grid containers
Inherited
no
Percentages
n/a
Computed value
as specified
Canonical order
per grammar
Animation type
not animatable

Browser support

First browser version supporting reading-flow
Chrome 137
Edge 137
Firefox No
Safari No
Chrome Android 137
Safari iOS No

First version with support, from MDN browser-compat-data.

reading-order

Property Limited availability Experimental Modern CSS: reading-flow

MDN The reading-order CSS property enables changing the order in which a child of a reading flow container is read relative to its element siblings.

Live preview Example from MDN
.wrapper {
  display: grid;
  grid-template-columns: repeat(3, 150px);
  grid-auto-flow: dense;
  reading-flow: grid-rows;
}

.top {
  reading-order: -1;
}

.bottom {
  reading-order: 21;
}

Syntax

<integer>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
0
Applies to
Direct block-level, grid item, or flex item children of a reading flow container.
Inherited
no
Percentages
n/a
Computed value
specified integer
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting reading-order
Chrome 137
Edge 137
Firefox No
Safari No
Chrome Android 137
Safari iOS No

First version with support, from MDN browser-compat-data.

visibility

Property Baseline: widely availablesince January 2018

MDN The visibility CSS property shows or hides an element without changing the layout of a document. The property can also hide rows or columns in a <table>.

Live preview Example from MDN
.example-container {
  border: 1px solid #c5c5c5;
  padding: 0.75em;
  width: 80%;
  max-height: 300px;
  display: flex;
}

.example-container > div {
  background-color: rgb(0 0 255 / 0.2);
  border: 3px solid blue;
  margin: 10px;
  flex: 1;
}

#example-element {
  background-color: rgb(255 0 200 / 0.2);
  border: 3px solid rebeccapurple;
}

Syntax

visible | hidden | force-hidden | collapse

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
visible
Applies to
all elements
Inherited
yes
Percentages
N/A
Computed value
as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting visibility
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

<display-box>

Type Limited availability

MDN These keywords define whether an element generates display boxes at all.

Live preview Example from MDN
p.secret {
  display: none;
}

Syntax

contents | none

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting <display-box>
Chrome 65
Edge 79
Firefox 37
Safari 11.1
Chrome Android 65
Safari iOS 11.3

First version with support, from MDN browser-compat-data.

<display-inside>

Type Baseline: widely availablesince July 2022

MDN 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

flow | flow-root | table | flex | grid | ruby

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting <display-inside>
Chrome 58
Edge 79
Firefox 53
Safari 13
Chrome Android 58
Safari iOS 13

First version with support, from MDN browser-compat-data.

<display-internal>

Type Baseline: widely availablesince January 2018

MDN 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 page defines those "internal" display values, which only have meaning within that particular layout mode.

Live preview Example from MDN
main {
  display: table;
}

div {
  display: table-row;
}

label,
input {
  display: table-cell;
  margin: 5px;
}

Syntax

table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption | ruby-base | ruby-text | ruby-base-container | ruby-text-container

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting <display-internal>
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

<display-legacy>

Type Baseline: widely availablesince January 2018

MDN CSS 2 used a single-keyword syntax for the display property, requiring separate keywords for block-level and inline-level variants of the same layout mode. This page details those values.

Syntax

inline-block | inline-table | inline-flex | inline-grid

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting <display-legacy>
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

<display-listitem>

Type Baseline: widely availablesince January 2018

MDN The list-item keyword causes the element to generate a ::marker pseudo-element with the content specified by its list-style properties (for example a bullet point) together with a principal box of the specified type for its own contents.

Syntax

<display-outside>? && [ flow | flow-root ]? && list-item

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting <display-listitem>
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

<display-outside>

Type Baseline: widely availablesince January 2018

MDN The <display-outside> keywords specify the element's outer display type, which is essentially its role in flow layout. 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-inside> keywords.

Syntax

block | inline | run-in

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting <display-outside>
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.