CSS
🎯 CSS display Property
The display CSS property defines how an HTML element is rendered on the page.
It controls whether an element behaves as block, inline, grid, flex, table, or is completely hidden from the layout.
🔹 Why Use display?
The display property is one of the most important CSS tools for building layouts and controlling page structure.
- Controls layout behavior of elements
- Enables flex and grid systems
- Helps build responsive designs
- Manages visibility and structure
🧩 display Values
1️⃣ inline
The element behaves like inline content and does not start on a new line.
span {
display: inline;
}
2️⃣ block
The element starts on a new line and takes full available width.
div {
display: block;
}
3️⃣ inline-block
Combines inline behavior with block features like width and height.
div {
display: inline-block;
}
4️⃣ none
The element is completely removed from the layout and not visible.
div {
display: none;
}
5️⃣ list-item
The element behaves like a list item and displays a marker.
div {
display: list-item;
}
6️⃣ table & table-* values
CSS can simulate table structures using display values like table, table-row, and table-cell.
- table → behaves like a table
- table-row → behaves like a row
- table-cell → behaves like a cell
- inline-table → inline table layout
7️⃣ flex & inline-flex
Enables flexible box layout for advanced alignment and responsive design.
div {
display: flex;
}
8️⃣ grid & inline-grid
Provides a grid-based layout system for complex page structures.
div {
display: grid;
}
9️⃣ initial
Resets the display property to its default browser value.
📌 Quick Summary
-
🧠 Overview
- inline → inline element behavior
- block → block-level element
- inline-block → inline but with block features
- none → hides element completely
- flex / grid → modern layout systems
