Lesson 10 of 50
cssDisplay Property
9 mins
Course progress20%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 10 of 50
css9 mins
Keep these ideas in mind as you work through the lesson.
display decides how an element participates in the visual flow of the document.
| Value | Layout Behaviour |
|---|---|
block | Takes the full width, starts on a new line. |
inline | Flows with surrounding text; width/height ignored. |
inline-block | Like inline but respects width/height. |
flex | Turns the element into a Flex container (one‑dimensional, flexible layout). |
grid | Turns the element into a Grid container (two‑dimensional layout). |
none | Removes the element from the render tree. Not visible, not focusable, not read by screen‑readers. |
list-item | Generates a bullet/number (useful for custom list styling). |
inline-blockCommon for button groups, navigation tabs, or icon + text combos where you need a box that behaves like text but still respects dimensions.
.nav-item {
display:inline-block;
margin-right:1rem;
}
flex and gridfloat, inline‑block hacks). Use them for all new UI unless you have a very specific reason to stay with older techniques.display:noneBecause display:none removes the element from the accessibility tree, it should only be used for content that truly does not belong in the DOM (e.g., modal dialogs that are closed). If you only need to hide something visually while keeping it readable by assistive tech, use visibility:hidden or opacity:0.