Open In App

What is display Property in CSS ?

Last Updated : 16 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The display property in CSS is a fundamental property that defines how an HTML element should be displayed in the layout. It controls the box type generated by an element and, consequently, its positioning and behavior within the document flow.

Syntax:

/* Example of using the display property */
.element {
display: value;
}

Common display Property Values:

This table provides a clear breakdown of CSS display values and their respective descriptions.

Display Value Description
block Generates a block-level container box. Starts on a new line and stretches the full width of its container.
inline Generates an inline-level box. Does not start on a new line and only takes up as much width as necessary.
inline-block Generates an inline-level box behaving as a block-level box. Does not start on a new line but allows setting width and height.
flex Generates a flex container enabling a flexible box layout, allowing items inside to be flex items.
grid Generates a grid container enabling grid layout, allowing items inside to be grid items.
none Removes the element from the layout entirely, making it invisible and taking up no space.

Features:

  • The display property is crucial for controlling the layout of elements.
  • It plays a significant role in implementing various layout models, such as block layout, inline layout, flexbox, and grid layout.
  • The choice of display value influences the box model, positioning, and interaction of elements within a webpage.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads