Nearby lessons
15 of 19📦 CSS Display Property
📌 What is CSS Display Property?
The display property in CSS determines how elements are displayed on the page. It's a key concept in layout design.
Common values include:
- block – Stacks elements vertically
- inline – Places elements in-line with surrounding text
- inline-block – Like inline, but allows width & height
- flex – One-dimensional layout
- grid – Two-dimensional layout
- none – Completely hides the element
🔹 display: block
Block elements take the full width and stack vertically. Default for <div>, <p>, etc.
Code Example
PREVIEW READY
🔹 display: inline
Inline elements flow with surrounding text and do not start on a new line.
Code Example
PREVIEW READY
🔹 display: inline-block
Inline-block combines inline flow with the ability to set width and height.
Code Example
PREVIEW READY
🔹 display: flex
Flexbox is a powerful 1D layout system that arranges items in rows or columns with flexible sizing.
Code Example
PREVIEW READY
🔹 display: none
Elements with display: none are not rendered and take up no space.
Code Example
PREVIEW READY
💡 Display Best Practices
- ✅ Use semantic tags first, then modify display if needed.
- ✅ Prefer Flex and Grid for modern layouts.
- 🚫 Avoid using display: none for accessibility-critical elements.
- ✅ Understand how display affects the box model.
- 📱 Test display behavior on different screen sizes.
🧠 Test Your Knowledge
5 QuestionsProgress: 0 / 5
Keep Going!CSS - Position