The display property is the most important CSS property for controlling layout.
The display property is used to specify how an element is shown on a web page.
Every HTML element has a default display value, depending on what type of element it is. The default display value for most elements is block or inline.
The display property is used to change the default display behavior of HTML elements.
A block-level element ALWAYS starts on a new line and takes up the full width available (stretches out to the left and right as far as it can).
The <div> element is a block-level element.
The display property has many values.
Value | Description |
---|---|
inline | Displays an element as an inline element |
block | Displays an element as a block element |
flex | Displays an element as a block-level flex container |
grid | Displays an element as a block-level grid container |
inline-flex | Displays an element as an inline-level flex container |
inline-grid | Displays an element as an inline-level grid container |
none | The element is completely removed. |
initial | sets this property to its default value |
inherit | inherits this property from its parent element |