Display - Property CSS
Summary of characteristics of the display
property
block
| inline
| list-item
| run-in
| contents
| none
| flex
| grid
| ruby
| table
| flow
| flow-root
| 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
| inline-block
| inline-flex
| inline-grid
| inline-table
inline
Not animable
: the display
property cannot be animated.
(1) Only a few values of display
have an effect on an SVG image.
Description of the display
property.
display
defines how to display an element: as a frame, on the line of text, and so on.
Each HTML element already has a default display mode, but the display
property allows you to change this mode.
In practice, it is rare to change the nature of a very specific element, such as an array element but display
is particularly
useful in the following cases:
- Make an element disappear (
display:none
).. - Declare a
flex
container. See the tutorial flex-box. - Declare a container
grid
. See the tutorial grids.
This page is quite long, so use these links to go directly to the display
value you're interested in:
block -
contents -
flex -
flow -
flow-root -
grid -
inine -
inline-block -
inline-flex -
inline-grid -
inline-table -
list-item -
none -
table -
table-caption -
table-cell -
table-column -
table-elements -
table-column-group -
table-header-group -
table-row -
table-row-group -
ruby -
ruby-base -
ruby-text -
ruby-base-container -
ruby-text-container -
run-in
Values for display
.
- display: none;
The item will not be displayed at all. The place it would have occupied is available for other elements.
- display: inline;
The item appears on the line of text without causing a line break. The dimensions of the element are defined by its content: it is not possible to change the width or height of an
inline
element with the CSSwidth
andheight
properties.Some HTML elements are displayed by default in
inline
mode: the links a, the input box input, the tag span, etc. img images are also inline elements (which is not obvious).Here's aninline element - display: block;
The element is displayed as a block: it will be preceded and followed by a newline and, unless otherwise specified, it will occupy the entire available width.
Many HTML elements are displayed by default in
block
mode: p paragraphs, titles h1, h2, h3..., div frames, as well as the section, article tags, etc.In the example below, the input tag that is normally of type
inline
has been changed to ablock
: there is a line break before and an after.Your name: - display: inline-block;
The element behaves on the line like an
inline
element, but its contents are handled as if it were a block: possibility of defining its dimensions, margins, etc. See the example below:The element oppositeIts content is managed like that of an element of theis of theblock
typeinline-block
type - display: list-item;
The item is displayed as a list item, with a bullet or number. This is the default display mode for li elements.
First item.Second item.Third item. - display: flex;
The element behaves like a
block
element and is also a flex container for the elements it contains. See the detailed explanations on the flex-box page.ABC - display: inline-flex;
The element behaves like an
inline
element and is also a flex container for the elements it contains. See the detailed explanations on the flex-box page.This element is on a lineABC - display: grid;
The element behaves like a
block
element and organizes the elements it contains in the form of a grid. See the detailed explanations on the grids page.ABCD - display: inline-grid;
The element behaves like an element of the
inline
type and is a container grid for the elements it contains (arrangement in the form of a grid). Refer to the detailed tutorial explanations on the grids page.This element is on a lineABC - display: contents;
The element is not displayed and is further removed from the DOM. In other words, its children (the elements it contains) take its place in the parent/child hierarchy.
For the purposes of the demonstration, we have applied a red background to the parent frame below. This color does not appear because this element has been given the
display:contents;
rule.ABC - display: table;
The item is displayed as a table. This is the default display mode for table elements.
In HTML, it is not recommended to use a tag other than table to define tables. Indeed, to display correctly, a table needs very specific internal elements, such as TR lines, TD cells, etc. It is therefore not enough to change the way the container is displayed.
However, in this example, we only used div tags. It was necessary to change their display mode in
table
for the container, and intable-row
andtable-cell
for the internal elements.ABC - display: inline-table;
The element behaves like an
inline
element and is also an array container for the elements it contains.This is an element that takes place on a line of textA B C D E F - display: table-caption; display: table-header-group; display: table-footer-group; display: table-row-group; display: table-row; display: table-column; display: table-column-group; display: table-cell;
All these values correspond to one of the constituents of an array.
table-caption
The title of the table. See also the CSS property caption-side
to position the title relative to the table.table-header-group
The header row(s) in a table. This is the default display mode for thead elements. table-footer-group
The footline(s) of a table. This is the default display mode for tfoot elements. table-row-group
The row(s) in the body of a table. This is the default display mode for tbody elements. table-row
A table line. This is the default display mode for tr elements. table-column
A table column. This is the default display mode for col elements. table-column-group
A group of table columns. This is the default display mode for colgroup items. table-cell
A table cell. This is the default display mode for td elements. - display: ruby;
The element is displayed as a ruby container. In a nutshell, a ruby structure allows a short text to be displayed above each character of a sentence explanation or phonetic information. This presentation is widely used in Japanese, Korean, etc. but we can find other uses for it, as below:
📧 ☎ 📠 📱In HTML it is advisable to use the ruby tag, dedicated to the ruby notation, rather than changing the mode standard tag display This is because the ruby structure needs specific internal elements to display correctly: rb, rt, etc. It is therefore not enough to change the way the container is displayed.
- display: ruby-base; display: ruby-text; display: ruby-base-container; display: ruby-text-container;
Each of these values corresponds to one of the constituents of a ruby structure.
ruby-base
Default display mode for rb tags. ruby-text
Default display mode for rt tags. ruby-base-container
Default display mode for rbc tags. ruby-text-container
ModDefault display mode for rtc tags. Here are some examples of
ruby
syntax. Ruby syntax is normally used with CJK characters, but we preferred to build our examples with graphic characters like a telephone.‹ruby› ‹rb›☎‹/rb› ‹rt›Tel‹/rt› ‹/ruby›
☎ ‹ruby› ‹rb›☎‹/rb› ‹rp›(‹/rp›‹rt›Tel‹/rt›‹rp›)‹/rp› ‹/ruby›
(1)☎ (1) The rp element is not displayed. It is only useful on browsers that do not support ruby syntax. It designates the characters (often parentheses) that will be used to distinguish the text part (rt).
- display: flow;
Most browsers equate this value with
block
. - display: flow-root;
The
flow-root
value generates a block container that encloses all of its contents. This solves the problem of a series of elements that have a floating element that may be larger than the text.L'exemple d'une image flottante à gauche, et suivie d'un texte dont la hauteur est insuffisante pour couvrir la hauteur de l'image.
The next frame shifts to the right of the previous frame.
With
display:flow-root
this problem does not arise.This image is correctly positioned below the previous one.
- display: run-in; ⚠
The element inserts at the beginning of the element that follows it. This allows for example to keep a title tag, for semantics, while inserting the title at the beginning of the following paragraph.
⚠ Careful! This value is not currently recognized by browsers.
Title
Next paragraph.The result should look like this (simulation):
Title. Next paragraph.
Common values:
display: initial (inline
)
display: inherit
display: revert
display: revertLayer
display: unset
These values are described in more detail on their respective page: initial
, inherit
, revert
, revert-layer
, unset
.
Interactive example with display
.
The simulator applies the chosen value to both the container and the four internal elements. The result is not necessarily very significant because some values require a particular construction of the HTML code.
✗ The ms-grid
value is only recognized by Internet Explorer, a browser that is now obsolete
Browsers compatibility.
The display
property is generally well supported by current browsers for values classics: block
, inline
, etc.
Some values, such as contents
, run-in
, still pose compatibility problems.
the display
property with most common values.contents
value for the display
property. run-in
value for the display
property.clearfix
hacking (see float
).Notes:
(1) The buttons are no longer accessible when display:contents
is applied.
(2) Partial support : severe implementation bugs that renders content inaccessible for many element types.
display
property
contents
value
run-in
value
flow-root
value
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

KaiOS Browser

Samsung Internet

Androïd Brower

Chrome pour Androïd

Baidu Browser

QQ Browser

Safari

Safari sur IOS

Chrome

Edge

Firefox

Opéra Mobile

UC Browser pour Androïd

Opéra

Firefox pour Androïd

Opéra mini
display
property historic.
The display
property has been around since the very first version of CSS, but it has undergone quite a few developments to adapt
to new features language, especially flex-box or grid layouts.
-
Cascading Style Sheets specification - Version 1
Initial property definition, with valuesblock
,inline
,list-item
andnone
.November 17, 1995Working Draft.November 12, 1996Proposed for recommendation.December 17, 1996Recommendation .September 13, 2018Old specification, declared obsolete. -
Cascading Style Sheets Level 2 - Revision 1 Specification
Adding theinline-block
value.November 04, 1997Working Draft.March 24, 1998Proposed for recommendation.May 11, 1998Recommendation . -
CSS Ruby Annotation Layout Module Level 1
Adding specific values for Ruby annotations:ruby
,ruby-base
,ruby-text
,ruby-base-container
andruby-text-container
.February 16, 2001Working Draft. -
CSS Display Module Level 3
Adding new values.February 20, 2014Working Draft.August 28, 2018Candidate Recommendation.
See also.
The CSS Display Module specification module that describes the display
property is very specific.
It includes only a few properties:
Properties:
