display

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

Initial value inline
Applies to all elements

Syntax

  
display: block;
  

Values

These keywords specify the element’s outer display type, which is essentially its role in flow layout.
The element generates a block element box, generating line breaks both before and after the element when in the normal flow.
The element generates one or more inline element boxes that do not generate line breaks before or after themselves. In normal flow, the next element will be on the same line if there is space
The element generates a run-in box. If the adjacent sibling of the element defined as display: run-in box is a block box, the run-in box becomes the first inline box of the block box that follows it. Run-in elements act like inlines or blocks, depending on the surrounding elements. That is: 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 an inline box follows, the run-in box becomes a block box.
These keywords specify the element’s inner display type, which defines the type of formatting context that its contents are laid out in (assuming it is a non-replaced element).
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.
The element generates a block element box that establishes a new block formatting context, defining where the formatting root lies.
These elements behave like HTML elements. It defines a block-level box.
The element behaves like a block element and lays out its content according to the flexbox model.
The element behaves like a block element and lays out its content according to the grid model.
The element behaves like an inline element and lays out its content according to the ruby formatting model. It behaves like the corresponding HTML elements.
The element generates a block box for the content and a separate list-item inline box.
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.
These elements behave like
HTML elements.
These elements behave like
HTML elements.
These elements behave like
HTML elements.
These elements behave like
HTML elements.
These elements behave like
HTML elements.
These elements behave like
HTML elements.
These elements behave like
HTML elements.
These elements behave like
HTML elements.
These elements behave like HTML elements.
These elements behave like HTML elements.
These elements behave like HTML elements generated as anonymous boxes.
These elements behave like HTML elements.
These values define whether an element generates display boxes at all.
These elements don't produce a specific box by themselves. They are replaced by their pseudo-box and their child boxes. Please note that the CSS Display Level 3 spec defines how the contents value should affect "unusual elements" — elements that aren’t rendered purely by CSS box concepts such as replaced elements. See Appendix B: Effects of display: contents on Unusual Elements for more details. Due to a bug in browsers this will currently remove the element from the accessibility tree — screen readers will not look at what's inside. See the Accessibility concerns section below for more details.
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 visibility property instead.
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.
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 flow-root.
The inline-table value does not have a direct mapping in HTML. It behaves like an HTML element, but as an inline box, rather than a block-level box. Inside the table box is a block-level context. It is equivalent to inline table.
The element behaves like an inline element and lays out its content according to the flexbox model. It is equivalent to inline flex.
The element behaves like an inline element and lays out its content according to the grid model. It is equivalent to inline grid.

Browser support

display 1 1 3.5 1 12 3

We use cookies to improve your experience. Learn more in our Privacy policy.

×