CSS display property
Example
Set different display values:
p
.ex1
{
display:
none
;
}
p
.ex2
{
display:
inline
;
}
p
.ex3
{
display:
block
;
}
p
.ex4
{
display:
inline-block
;
}
Try it »
Property definition and usage
The display 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 layout, or flex layout.
Formally, the display property sets the inner and outer display types of an element.
| Default value: | inline |
|---|---|
| Inherited: | no |
| Version: | CSS1 |
| JavaScript syntax: | object.style.display="inline" |
/* preset values */
display
:
block
;
display
:
inline
;
display
:
inline-block
;
display
:
flex
;
display
:
inline-flex
;
display
:
grid
;
display
:
inline-grid
;
display
:
flow-root
;
/* generate boxes */
display
:
none
;
display
:
contents
;
/* two-value syntax */
display
:
block
flow
;
display
:
inline
flow
;
display
:
inline
flow-root
;
display
:
block
flex
;
display
:
inline
flex
;
display
:
block
grid
;
display
:
inline
grid
;
display
:
block
flow-root
;
/* other values */
display
:
table
;
display
:
table-row
;
/* All table elements have a value equivalent to a CSS display property */
display
:
list-item
;
/* global values */
display
:
inherit
;
display
:
initial
;
display
:
revert
;
display
:
revert-layer
;
display
:
unset
;
Browser support
The numbers in the table indicate the first browser version that supports this property.
A number immediately before -webkit-, -ms-, or -moz- indicates the first browser version that supports that prefixed property.
| property | |||||
|---|---|---|---|---|---|
| display | 4.0 | 8.0 | |||
| Partial from 5.5 | 3.0 | 3.1 | 7.0 |
Attribute values
| Value | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| none | This element is not displayed. | ||||||||||||||||||||||||
| block | This element is displayed as a block-level element, with line breaks before and after it. | ||||||||||||||||||||||||
| inline | Default. This element is displayed as an inline element, with no line breaks before or after it. | ||||||||||||||||||||||||
| inline-block | An inline-block element. (A value added in CSS2.1) | ||||||||||||||||||||||||
| list-item | This element is displayed as a list. | ||||||||||||||||||||||||
| run-in | This element is displayed as a block-level or inline element depending on the context. | ||||||||||||||||||||||||
| compact | CSS has a compact value, but it was removed from CSS2.1 due to lack of widespread support. | ||||||||||||||||||||||||
| marker | CSS has a marker value, but it was removed from CSS2.1 due to lack of widespread support. | ||||||||||||||||||||||||
| table | This element is displayed as a block-level table (like
|